Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB problem for excel

Posted on 2003-02-19
2
Medium Priority
?
264 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Make the most of your online learning experience.
Simple Linear Regression
Screencast - Getting to Know the Pipeline

578 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