View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JP[_4_] JP[_4_] is offline
external usenet poster
 
Posts: 897
Default Write a branch to another macro

Sub MyMacro()

If Worksheets("mysheet").Range("B7").Value = 1 Then
Call Macro1
ElseIf Worksheets("mysheet").Range("B7").Value = 2 Then
Call Macro2
Else MsgBox "Incorrect Entry"
End If

End Sub


HTH,
JP

On Apr 9, 8:01*pm, iashorty
wrote:
I want to write an IF statement in VBA whe if cell B7=1 then run macro
Ctrl+a if cell B7=2 run macro Ctrl+b otherwise return a message "Incorrect
entry".