How to start a macro with a if statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top