ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Embeddding a macro in Logical IF stmt (https://www.excelbanter.com/excel-programming/298576-embeddding-macro-logical-if-stmt.html)

ron

Embeddding a macro in Logical IF stmt
 
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!

Ron de Bruin

Embeddding a macro in Logical IF stmt
 
Hi

Do you mean a IF statement in a formula or in code?

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron" wrote in message ...
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!




Bob Phillips[_6_]

Embeddding a macro in Logical IF stmt
 
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" wrote in message
...
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!




Ron de Bruin

Embeddding a macro in Logical IF stmt
 
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

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Hi

Do you mean a IF statement in a formula or in code?

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron" wrote in message ...
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!







All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com