Results 1 to 2 of 2

Thread: formula to run macro

  1. #1

    formula to run macro

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

    Hi. Just new to this site. It looks very informative. I have a question. Is it possible to have an IF formula qualify certain criteria and then command a macro?

  2. #2
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Excel Version
    Try this:
    in cell F13 your IF formula, say:

    Right-click that sheet's tab and paste these two macros:
    Private Sub Worksheet_Calculate()
    If Range("F13") = True Then blah
    End Sub
    Sub blah()
    MsgBox "Hello!"
    End Sub
    Now change E13 and D13 on the sheet to the same.

    You could do this another way, a bit shorter by eliminating the IF formula in cell F13 and deleting the Sheet_Calculate event handler (macro), replacing it with the sheet_change event handler:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("D13") = Range("E13") Then blah
    End Sub

Posting Permissions

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