+ Reply to Thread
Results 1 to 3 of 3

can i use an IF Statement to run a macro?

  1. #1
    Davidrowland88
    Guest

    can i use an IF Statement to run a macro?

    i am using excel 2000. I want to know if you can use an IF Statement to run a
    macro. E.G If a cell equals 1 then run a certain macro

  2. #2
    JE McGimpsey
    Guest

    Re: can i use an IF Statement to run a macro?

    No, in general, formulas can only return values to their calling cells.
    However, you can use an event macro that will check your cell each time
    the sheet is calculated, say, and run the macro if the value of the cell
    is 1. Put this in your worksheet code module (right-click the worksheet
    tab and choose View Code):

    Private Sub Worksheet_Calculate()
    If Range("A1").Value = 1 Then MyMacro
    End Sub

    where MyMacro is the name of your macro.


    In article <4554A445-DE8D-4A4F-9DE5-515C622CE1D3@microsoft.com>,
    "Davidrowland88" <Davidrowland88@discussions.microsoft.com> wrote:

    > i am using excel 2000. I want to know if you can use an IF Statement to run a
    > macro. E.G If a cell equals 1 then run a certain macro


  3. #3
    Ron Rosenfeld
    Guest

    Re: can i use an IF Statement to run a macro?

    On Fri, 11 Feb 2005 04:25:02 -0800, "Davidrowland88"
    <Davidrowland88@discussions.microsoft.com> wrote:

    >i am using excel 2000. I want to know if you can use an IF Statement to run a
    >macro. E.G If a cell equals 1 then run a certain macro


    By IF statement I assume you mean the IF worksheet function; and not an IF
    statement within the macro itself.

    Probably not as a worksheet function cannot change another cell.

    However, you could set up your macro as an event-triggered macro, and within
    the macro test to see if the cell equals 1.


    --ron

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1