Using IF to decide action

  • Thread starter Thread starter a m spock
  • Start date Start date
A

a m spock

I have two options to act in ActiveCell depending on value of cell in the
third column to the left of active cell i.e. Offset(0,-3). I have two
separate macros say Macro1 and Macro2 to call depending on if the value is
 
Hi

You can use like the following

=IF(A3>=1,MAcro2(),Macro1())


where Macro1 and Macro2 are functions like :

Public Function MAcro1()

MAcro1 = "Macro1 Executed "
MsgBox "Macro1 Executed "

End Function

Public Function MAcro2()

MAcro2 = "Macro2 Executed "
MsgBox "Macro2 Executed "

End Function

Cheers
Shasur
 
Try this

If ActiveCell.Offset(, 3).Value >= 1 Then
'Macro1
ElseIf ActiveCell.Offset(, 3).Value < 1 Then
'macro2
End If

Mike
 
I should have added that having called a function from a cell in this way the
functionality you then have is very limited. I would need a very compelling
and specific reason before I would do this.
 
many thanks mike. this is what i needed. will try it out and get back if
there are any issues.
 
This is what has worked.

If ActiveCell.Offset(0, -3).Value >= 1 Then
Call Sale
ElseIf ActiveCell.Offset(0, -3).Value < 1 Then
Call Sale2
End If

many thanks once again.
 
dear mike,
in a parallel situations what would need to be done if i need to skip all
action for offset(0,-3).value >=1 and move down in the column until i find a
cell with the corresponding offset(0,-3).value <1 then call macroX

ams
 
Back
Top