macro from a cell...?

  • Thread starter Thread starter Nessuno
  • Start date Start date
N

Nessuno

hi to all...
is it possible to launch a macro from an instruction in a cell?
p.e. =IF(C2="X"; run mymacro; "")
thanks...
 
Not from a formula like you have it, but you can run a macro if the value in
C2 is "X". You would use a sheet macro to do that. Provide more
information about what you want to do. For instance, is C2 the only cell in
which you want this to happen? And is "X" the only value that you want to
use as a trigger? HTH Otto
 
Not from a formula like you have it

my formula is just an example. i don't know if this is the right syntax but
the idea...

but you can run a macro if the value in
C2 is "X".

Yes! i want this!!! ;))
For instance, is C2 the only cell in which you want this to happen? And
is "X" the only value that you want to use as a trigger?

for the moment this is enough.

thanks again
 
Right-click on the sheet tab and select View Code. Paste this macro into
that module. "X" out of the module to return to your sheet. This macro
will run the macro named "MyMacro" if the value of C2 changes to "X". Post
back if you need more. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C2")) Is Nothing Then
If Target.Value = "X" Then Call MyMacro
End If
End Sub
 
Otto Moehrbach said:
Right-click on the sheet tab and select View Code. Paste this macro into
that module. "X" out of the module to return to your sheet. This macro
will run the macro named "MyMacro" if the value of C2 changes to "X".
Post back if you need more. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C2")) Is Nothing Then
If Target.Value = "X" Then Call MyMacro
End If
End Sub

....sorry...i've formatted my pc... so...another question...(please don't
hate me)
is this way a real time checker? I mean: when i put "X" value in C2 MyMacro
starts or it will happens on worksheet reload?
bye... and thanks... :))
 
You must manually enter an "X" in C2 for the code to trigger your macro.

If you want something else, you will need different type of event.


Gord Dibben MS Excel MVP
 
Back
Top