Run a macro when cell value changes

  • Thread starter Thread starter Emea training
  • Start date Start date
E

Emea training

I have a macro that I would like to run, onlly when a particular cel
value reaches a pre-defined value.

I really do not know how to do this - I have looked on help features
but to no avail. any ideas
 
right click sheet tab>view code>copy/paste this>modify to suit>save
Now when cell c1 calculates to >32 your macro will fire

Private Sub Worksheet_Calculate()
If Range("c1") > 32 Then call yourmacro ' MsgBox "Hi"
End Sub
 
Great answer,
I have a little bit near question, is it possibl
to do it without having any number, if i enter into a particular blan
cell say 'J2', to activate the macro or run the macro.
thank u.
nowfa
 
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Address = "$B$3" Then
If Target.Value > 100 Then
Call macroname
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on your worksheet tab and "View Code"

Copy/paste the above code into that sheet module.

Your cell reference and value may vary. Adjust to suit. Also change
"macroname" to your macro name.

Gord Dibben Excel MVP
 
Does "enter into a particular blank cell" mean you typed something into it or
just selected it?
 
I just wanted to select it, neither number nor text in that cell, an
new ideas.
thank
 
In the worksheet's module:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "Changed"
End Sub

It can be confusing to see only part of a thread. This is a draw back of
using a web-based forum.
You might find it better to use the source newsgroup
(microsoft.public.excel.misc).

--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"
 

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