Trigger a specific macro to run

  • Thread starter Thread starter Jay Gustafson
  • Start date Start date
J

Jay Gustafson

Hello,

This question is related to a question I had posted in the 'charting'
section, but I have a new idea which I feel might solve my problem.

if D67 = any value then run 'Macro1'.
if D68 = any value then run 'Macro2'.
if D69 = any value then run 'Macro3'.
if D70 = any value then run 'Macro4'.
if D71 = any value then run 'Macro5'.

Is this even possible?

Thank you,
Jay Gustafson
 
Jay

Yes! its possible, but it will tike a bit of programing,
this time no in a Module but in the sheet where all those
D# are...

1.- Clik with the right button on the sheet tan were you
have your references.
2.- Go to View Code (bottom of the list)
3.-This should take you to a VBA code page, with two drop
down menus, one that says "(General)" and another one that
says "(Declarations)"...
4.- Change the "(General)" one to Worksheet via the drop
down, by default it will appear on the declaration
side:"Selection Change" menaing this code will reevaluate
every time you change selection...
5.- This should appear as well in the code area:

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)

End Sub

6.- your code should look something like this:

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)

If Range("D16").Value = "Any Value" Then
Application.Run "MyMacro_1"
If Range("D17").Value = "Any Value" Then
Application.Run "MyMacro_2"

'and so on

End Sub

Since this will recalculate every time you change
selection, this is, every time there is a cell change, you
might want to add some reseting code on your macros so
that i doesn't run over and over again.

Hope this helps.

Cheers
Juan
 
Jaun,

I want to thank you very much for taking the time to help me with my
problem. I was excited to see that you had a solution for me, but when I
read your last paragraph, that had never crossed my mind. After reviewing
it, I think more of my report has to be explained to get a CLEAR picture of
exactly what I need done.

Would you mind if I e-mailed you the report directly, so you could have a
look at it and help me work out a solution or atleast my options.
Unforuntaly, I have no experience in working in the VBA, View code section.
I have been in it before, to copy & paste a code, but other than that, I
can't edit it, or know how to write the code.

So it's your call. If you would like the file, with more of an explanation
in the file let me know and I'll send it to you. If not, that's fine. I
understand as this is a huge request and I'm sure you have your own reports
to worry about.

Anyhow, let me know.

Thank you,
Jay Gustafson
 
Jay

Bring it on... there are no spam traps on my mail so use
it as it appears, include in the mail a clear explanation
of what you want it to do...

Cheers...
Juan
 
Back
Top