98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Perform a macro whenever the Sheet is updated | VBA forum
vba courses london - Perform a macro whenever the Sheet is updated | VBA forum
Resolved · Low Priority · Version Standard
Julian has attended:
Excel VBA Intro Intermediate course
Perform a macro whenever the Sheet is updated
Hi there,
Everytime I change a drop down box or any data on the sheet changes I want a macro to execute. The macro is in place of a 'nested IF' formula as they are limited to 7 x IFs.
I remember from the course that if you put a proceedure in the 'ThisWorkbook' module it will execute when anything on a specified sheet is updated. but I cant make it work. I tried putting the following in:
Sub auto_change()
Range("C26").Select
If ActiveCell = 10 Then
Range("D26") = 0
ElseIf ActiveCell = 20 Then
Range("D26") = 1
ElseIf ActiveCell = 21 Then
Range("D26") = 2
ElseIf ActiveCell = 22 Then
Range("D26") = 3
ElseIf ActiveCell = 23 Then
Range("D26") = 4
ElseIf ActiveCell = 30 Then
Range("D26") = 5
ElseIf ActiveCell = 31 Then
Range("D26") = 6
ElseIf ActiveCell = 32 Then
Range("D26") = 7
ElseIf ActiveCell = 33 Then
Range("D26") = 8
End If
End Sub
Many thanks
julian
RE: Perform a macro whenever the Sheet is updated
The macro won't work on its own. All you have done is save it in the Workbook's module. To run the code:
On the code page for the relevant worksheet
Create an event procedure for the Worksheet called
Worksheet_SelectionChange
Call the macro from it OR Copy the code into the procedure
If it still doen't work with this event, then try the Event procedure
Worksheet_Change
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
VBA tip:Stuck in a Code LoopIf you ever get stuck in an infinite code loop when programing in VBA use |