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!

    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.

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Location
    Nanaimo, BC, Canada
    Posts
    2,195
    Articles
    57
    Blog Entries
    14
    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,
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/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
  •