?
Solved

VB problem for excel

Posted on 2003-02-19
2
Medium Priority
?
260 Views
Last Modified: 2010-08-05
I have an excel spreadsheet and I want to be able to input a number into a cell , which on entering will automatically divide it by 100, without using a visible formula.  This would apply to a range of cells (A1 to A50)

0
Comment
Question by:Prickle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
MCummings111400 earned 200 total points
ID: 7983747
Copy and Paste the following code into your sheets code module. (In Excel hit ALT-F11, then double click the name of your sheet)

This will divide the cells from A1 to A50 by 100


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Static bCritical As Boolean

    On Error GoTo err_Handler
    If Not bCritical Then
        bCritical = True
    Else
        Exit Sub
    End If
   
    For Each Cell In Target.Cells
        If Cell.Column = 1 And (Cell.Row >= 1 And Cell.Row <= 50) Then
            Cell.Value = CDec(Cell.Value) / 100
        End If
               
    Next Cell
   
err_Handler:
    bCritical = False
End Sub
0
 

Author Comment

by:Prickle
ID: 7987290
Abosolutly bang on. Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question