Creating macros with if stmts
Hi,
There are many ways to do this. Here's one. You would of course change the
msgbox in this example to your code.
Sub macro()
Select Case Range("A1").Value
Case Is = 1
macro1
Case Is = 2
macro2
Case Is = 3
macro3
Case else
'Do soemthing else
End Select
End Sub
Sub macro1()
MsgBox 1
End Sub
Sub macro2()
MsgBox 2
End Sub
Sub macro3()
MsgBox 3
End Sub
Mike
"Lisa12" wrote:
I am new to macros and I need to create a macro with an if statement. What
is the correct format, including spacing to make this work? I know the
wordin is If and else, but I can't seem to get the right format. Lets say if
A1=1 I want the first macro to work, if A1=2 I want the 2nd macro to work,
and if A1=3 the third.
Sub
Macro
End Sub
Sub
Macro
End Sub
Sub
Macro
End Sub
Any help would be appreciated, like I said I just can't quite make it work.
Thank you,
Lisa12
|