Results 1 to 2 of 2

Thread: worksheet calculate mcro

  1. #1

    worksheet calculate mcro

    Register for a FREE account, and/
    or Log in to avoid these ads!

    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.

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Nanaimo, BC, Canada
    Blog Entries
    Excel Version
    Excel Office 365 Insider
    Hi there,

    You're actually looking for a Worksheet_Change event, not calculate, I think. Here's the framework:
    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
            Case Is = "$B$5"
                'Do something
        End Select
        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,
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book Master Your Data for Excel and Power BI, or our new Power Query Recipe cards!

    Main Site: -||- Blog: -||- Forums:
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts