ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to start a macro with a if statement (https://www.excelbanter.com/excel-programming/375804-how-start-macro-if-statement.html)

Philippe_seattle

How to start a macro with a if statement
 
Hello there,

Do you know if it is possible to start a macro from an if statement? For
examle, if A1=foo, run macro1.

I am trying to hide a few rows when a given information is entered

JMB

How to start a macro with a if statement
 
Right click on your worksheet tab, select view code and paste this code into
the code window

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address = "$A$1" And .Value = "foo" Then Call macro1
End With
End Sub


"Philippe_seattle" wrote:

Hello there,

Do you know if it is possible to start a macro from an if statement? For
examle, if A1=foo, run macro1.

I am trying to hide a few rows when a given information is entered



All times are GMT +1. The time now is 03:01 AM.

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