ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to run a macro when a worksheet is selected (https://www.excelbanter.com/excel-worksheet-functions/37280-how-run-macro-when-worksheet-selected.html)

cpmittal

How to run a macro when a worksheet is selected
 

Can anyone help how to autrun a macro when a worksheet is selected.


--
cpmittal
------------------------------------------------------------------------
cpmittal's Profile: http://www.excelforum.com/member.php...o&userid=25641
View this thread: http://www.excelforum.com/showthread...hreadid=390498


aristotle

Hi,

This works whenever a change is made within a worksheet, will it do?

Go to VBE (Alt + F11). Find the sheet you want to apply this to within
Project-VBA Project. Double click the sheet and paste:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
YourMacro
End Sub

Change "YourMacro" to the code you want to run.

Regards,
A

"cpmittal" wrote:


Can anyone help how to autrun a macro when a worksheet is selected.


--
cpmittal
------------------------------------------------------------------------
cpmittal's Profile: http://www.excelforum.com/member.php...o&userid=25641
View this thread: http://www.excelforum.com/showthread...hreadid=390498



Bob Phillips

Us

Private Sub Worksheet_Activate()
YourMacro
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"aristotle" wrote in message
...
Hi,

This works whenever a change is made within a worksheet, will it do?

Go to VBE (Alt + F11). Find the sheet you want to apply this to within
Project-VBA Project. Double click the sheet and paste:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
YourMacro
End Sub

Change "YourMacro" to the code you want to run.

Regards,
A

"cpmittal" wrote:


Can anyone help how to autrun a macro when a worksheet is selected.


--
cpmittal
------------------------------------------------------------------------
cpmittal's Profile:

http://www.excelforum.com/member.php...o&userid=25641
View this thread:

http://www.excelforum.com/showthread...hreadid=390498






All times are GMT +1. The time now is 05:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com