Worksheet_Activate event between worksheets

krrishkrsna

Board Regular
Joined
Jan 31, 2009
Messages
84
Hi

unable to execute events between worksheets

in Sheet1 worksheet event
private sub Worksheet_Activate()
Msgbox "Hi"
End Sub

in sheet2 worksheet event
private sub Worksheet_Activate()
Application.Run "Sheet1.Worksheet_Activate"
End Sub

after googling used friend or public in place of private but no result. plz help
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

code does fine for me as long as the codename of the first sheet is Sheet1 and the codes are placed behind the corresponding worksheets. Have you checked that the events are on for by putting this line in the immediate window and press enter

VBA Code:
?Application.DisplayAlerts

In the future please make use of the code-tags available for displaying your procedures.

Ciao.
Holger
 
Last edited:
Upvote 0
Hi,

code does fine for me as long as the codename of the first sheet is Sheet1 and the codes are placed behind the corresponding worksheets. Have you checked that the events are on for by putting this line in the immediate window and press enter

VBA Code:
?Application.DisplayAlerts

In the future please make use of the code-tags available for displaying your procedures.

Ciao.
Holger
today works perfectly below codes
in sheet1
Private Sub Worksheet_Activate()
MsgBox "Hi"
End Sub

in sheet2
Private Sub Worksheet_Activate()
Application.Run "Sheet1.Worksheet_Activate"
End Sub

but no results for below code in sheet2
in sheet1
Private Sub Worksheet_Activate()
Dim wkshtnm As Worksheet, i As Integer
i = 1
For Each wkshtnm In ThisWorkbook.Worksheets
Range("A" & i) = wkshtnm.Name
i = i + 1
Next wkshtnm
End Sub

in sheet2
Private Sub Worksheet_Activate()
Application.Run "Sheet1.Worksheet_Activate"
End Sub
 
Upvote 0
In Worksheet 2 (assuming you haven't changed the Name of Sheet1)
VBA Code:
Private Sub Worksheet_Activate()
Sheet1.Activate
End Sub
 
Upvote 0
In ThisWorkbook

VBA Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
  Range("A1").Value = Sh.Name
End Sub

Holger
 
Upvote 0
In Worksheet 2 (assuming you haven't changed the Name of Sheet1)
VBA Code:
Private Sub Worksheet_Activate()
Sheet1.Activate
End Sub
Hi,

Sorry i was not well to look into the solution provided by you. actually i am in need of execution of Sheet1 event macros in other sheets but your solution selecting always sheet1
 
Upvote 0
You might find it easier to achieve what you are trying to do by using the workbook sheet activate event instead of all the individual worksheet activate events
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

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