PDA

View Full Version : Solved: Runing a macro by clicking on a sheet



dani9
07-22-2011, 12:52 AM
Hi,

so far you have been very helpfull, so I hope you will help me with this problem also :)

I need to run macros by clicking on a certain worksheet.

So far I have got this:
Sub Worksheet_Activate()
Call ColorBackgorund
Call SetColour
Call RecalculateColor
End Sub

Can it be done, to call the whole Module2, where all the subs are.
And i need it to activate on clicking on worksheet "Performance Report"

thanks in advance!

dani9
07-22-2011, 12:56 AM
Fixed it myself!

Sub Worksheet_Activate()
Call Module2.ColorBackground
Call Module2.RecalculateColor

End Sub


if anyone will need this in the future, here it is!

thanks again!

Kenneth Hobs
07-22-2011, 05:57 AM
You don't need to prefix with a Module name unless you use the same Sub name in other Modules. That is not something that I would recommend but if you do, prefixing is required.

Sub Worksheet_Activate()
ColorBackgorund
SetColour
RecalculateColor
End Sub