Embeddding a macro in Logical IF stmt

R

Ron

Hi

I am trying to embed a macro in a logical IF statement in the true result. Is this even possible, and if so how

Thanks for your help!
 
B

Bob Phillips

Ron,

I guess that you mean a worksheet IF. You can, but the things that macro can
do are limited. It would need to be a function, and it can return a value,
but it cannot change any properties of the cell/worksheet.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Ron said:
Hi,

I am trying to embed a macro in a logical IF statement in the true result.
Is this even possible, and if so how?
 
R

Ron de Bruin

Hi ron

You posted private that you use it in a formula
Try to use the calculate event in the Sheet module

This example will run the macro "YourMacroName" If the formula cell B1 display a value
higher then 10

Private Sub Worksheet_Calculate()
If Me.Range("b1").Value > 10 Then
YourMacroName
Else
'do nothing
End If
End Sub
 
Top