How do I get a macro to run automatically when a specific value i.

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

Guest

I want a macro to run automaticaly when I enter a specific value in a
specific cell on a specific worksheet
 
You have to put the macro in the Worksheet_Change event (in the specific
worksheeet's code module):

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range(SpecificCell)) Is Nothing Then
If Range(SpecficCell) = SpecificValue Then
'your macro steps
End If
End If
End Sub
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$H$1" Then
myMacro
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
if I want to run it automatically in works sheet, Can I use this way ?
 
At least try it and see.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
First of all thanks for your help. Although this code works its not quite
what I was looking for, I will try to explain in more detail. Cell B1 is
linked as a list to a list of names on another worksheet, when you select one
of the names from the list, it automatically changes the value in cell B2, to
a value between the numbers 226 and 300, using a lookup formula again this
is refering to a list on the other worksheet. it is when this value changes
I want the macro to run. The macro is for the purpose of selecting various
custom views which relate to the value chosen in cell B2. I hope this
explains my problem and you or someone out there has a soloution.
 

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