• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Perform Macro If Cell Changes

gumbles

New Member
Hello all,


I have a small recorded macro that copies one list of cells (Week 1) to another list (Week 2) then deletes the first list.


I would like to make this macro run automatically when the cell L2 changes. They are the current week and the next week so this needs to happen each week.


Regards,


Gumbles
 
Gumbles


Add the following code to the Worksheet Object in VBA of the worksheet that you want it to apply to

not to a Normal VBA Module


Change the cell address to suit

[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$2" Then
Call MyCode 'Call your code here
End If
End Sub
[/pre]
 
Brilliant!


Thanks Very much Hui.


I have one question though. The data in $B:$2 will change when the week changes and this will happen before the macros are enabled as They have to be turned on. Will this affect the operation of the code or should it work regardless?


Gumbles.
 
Back
Top