worksheet calculate mcro

lburch

New member
Joined
Nov 10, 2011
Messages
2
Reaction score
0
Points
0
Hi,
i have cells that say "no" in sheet1 that are then linked to another sheet via a formula, when they say yes i want a macro to run eg when cell a1 goes from "no" to "yes" run macro 1, when a2 goes from "no" to "yes" run macro 2 etc.
Also to stop a continuous loop when each macro has been run i want the cell to be cleared/empty.
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,520
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
Hi there,

You're actually looking for a Worksheet_Change event, not calculate, I think. Here's the framework:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo ExitPoint
    Application.EnableEvents = False
    Select Case Target.Address
        Case Is = "$A$1"
            'Do something
            Target.ClearContents
        Case Is = "$B$5"
            'Do something
            Target.ClearContents
    End Select
ExitPoint:
    Application.EnableEvents = True
End Sub

It needs to go in the Sheet module for the sheet you want to run it on. Update your cell references, and then plug the code in at the "Do Something" part.

Hope it helps,
 
Top