ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IF statement in a macro (https://www.excelbanter.com/excel-programming/327574-if-statement-macro.html)

iamn94

IF statement in a macro
 
Hello
New to macro writing so my question is pretty basic...

I want the macro to run only if the value of reference cell is less than a
certain return. For example, if the return is less than 30% run the macro.
If the return is greater than or equal to 30% do not run the macro.

How do I go about doing this? The rest of my macro works fine, I just need
to limit the range of its use.

Any and all help is appreciated.

Thanks
--
sd

William[_2_]

IF statement in a macro
 
Hi...

Sub Test()
With ThisWorkbook.Sheets("Sheet1")
If .Range("B3") < 100 Then Exit Sub
'Your code here
MsgBox "Cell B3 is greater than 99"
End With
End Sub

-----
XL2003
Regards

William




"iamn94" wrote in message
...
Hello
New to macro writing so my question is pretty basic...

I want the macro to run only if the value of reference cell is less than a
certain return. For example, if the return is less than 30% run the
macro.
If the return is greater than or equal to 30% do not run the macro.

How do I go about doing this? The rest of my macro works fine, I just
need
to limit the range of its use.

Any and all help is appreciated.

Thanks
--
sd





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

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