MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Running a macro from an IF statement

Posted by Andrew Leeson on April 26, 2001 5:38 AM

IS it possible to run a macro from an IF statement, if
so what is the format of the command?
I'm thinking of something like

What I am trying to do is match up two lists, the first with
about 2000 items and the 2nd with a subset of it that
is about 100 items.

Posted by Kevin James on April 26, 2001 7:06 AM


To answer your question, no.

However, I did exactly what you are trying to do without macros or VBA.

My scenario was:
Column A: Vlookup function, explained later
Column B: The master list of all users from our logon domain server.
Column C: The list of machine names used by the above users so I know which to schedule the SMS push for.
Column D: A list of users requesting an upgrade on an in-house application.

The vlookup was: For every match of column A in column D, put a 1 in column A.
To accentuate the finds, I put a conditional format in column C that highlighted the machine name in yellow if column A in the corresponding row was "1".

Posted by Andrew Leeson on April 26, 2001 7:56 AM

That works. Thanks.

I looked up Vlookup and it does indeed provide a
much easier way of doing what I was attempting to
Thank you.