Start Macro when a speecific sheet is active

CliffMc

New Member
Joined
May 23, 2003
Messages
15
HI,

I have been trying to use a "Private Sub" to start a Macro when I select a specific worksheet with in the workbook. But I am having trouble with the syntax. Not sure if I should be using WorkSheet_SelectionChange or WorkBook_sheetchange.

Here are a couple of variations that i have tried but no luck

Private Sub Worksheet_selectionChange(ByVal target As Excel.Sheet)
If target.Address = "Reconciliation" Then Call Recon
End Sub

And

Private Sub Workbook_Changesheet(ByVal target As Excel.Sheet)
If target.Address = "Reconciliation" Then Call Recon
End Sub

Any help would be greatly appreciated

Thanks

Cliff
:oops:
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try:

Private Sub Worksheet_Activate
If Your Condition Then
End If

Hope that helps,

Smitty
 
Upvote 0
Right click the tab for sheet Reconciliation and choose View Code. In the left hand dropdown choose Worksheet. You will get this:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

which is the procedure stub for the default event and which you can delete. In the right hand dropdown choose Activate. You will get this:

Code:
Private Sub Worksheet_Activate()

End Sub

to which you should add:

Code:
Call Recon
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,167
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top