Sheet msgbox

  • Thread starter Thread starter Fraggs
  • Start date Start date
F

Fraggs

I have a msgbox that I wish to appear when a sheet is active, I hav
tried the code:
Private Sub Workbook_SheetActivate

But that doesnt seem to be working. Any ideas as to how to fix thi
problem?

Regards
 
And if you only want it to appear when a single sheet is activated, you could
put your procedure under the worksheet module itself.

But the code will look more like:

Option Explicit
Private Sub Worksheet_Activate()
msgbox "hi from " & me.name
End Sub

And it'll run when the worksheet is activated. But if that sheet is active when
you open the workbook, your code won't run until you get off that sheet and come
back.

If you have multiple sheets that get the same behavior, you could use that
workbook_sheetactivate and add a test or two your code:

Option Explicit
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If LCase(Sh.Name) Like "sheet*" Then
MsgBox "hi from " & Sh.Name
End If
End Sub

(This is behind the thisworkbook module.)
 
Back
Top