Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a Macro from a conditional statement in a cell 1

Status
Not open for further replies.

Rougy

Programmer
Oct 15, 2001
249
US
Is there any way to call a macro from an IF/THEN statement within a cell?
 
Rougy,

I take this to mean you want to call a macro based on the result of the IF formula in a cell. If this is the case, then you should... First assign a Range Name to the cell containing the formula. In the following example VBA code, I use the Range Name "testcell"...

Dim value1 As Double

Sub Example()
value1 = Range("testcell")
If value1 = 123 Then Do_This
If value1 <> 123 Then Do_That
End Sub

Sub Do_This()
ActiveCell.Offset(0, 4).Select
End Sub

Sub Do_That()
ActiveCell.Offset(4, 0).Select
End Sub

I hope this helps. Let me know if you still require help.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top