Message Box

Roopen

Board Regular
Joined
Apr 10, 2008
Messages
158
Hi All,

Is there a way that I could have a message box appear if a user of my excel spreadsheet goes to different tabs?

I currently have the following appear on the model when the workbook is opened but want to have different message on each tab they select

Private Sub Workbook_Open()
MsgBox "Please note that 3% Salary Increases have been added from July!", vbInformation
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Use SheetActivate in ThisWorkbook module.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
   ' Some code
End Sub
 
Upvote 0
Hi,

Sorry for sounding a little thick... I have used the code you have supplied and come up with the below... It doesnt seem to work though!!

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
MsgBox "Please note that 3% Salary Increases have been added from July!", vbInformation
End Sub
 
Upvote 0
Hey Roopen,
the code works, you have to insert it into the "ThisWorkbook" Module in the VBA editor.

If you just want to have the message pop up for certain sheets you can either use this code and insert it into the Sheet modules
Code:
Private Sub Worksheet_Deactivate()
MsgBox "Please note that 3% Salary Increases have been added from July!", vbInformation
End Sub
(It lets the msg pop up everytime the user leaves the sheet)

Or this, which does the same when the sheet is entered.
Code:
Private Sub Worksheet_Activate()
MsgBox "Please note that 3% Salary Increases have been added from July!", vbInformation
End Sub

Cheers
Jan
 
Last edited:
Upvote 0
You want message box pop up when user selects sheet. What's wrong with my code?
 
Upvote 0
Hi Jan,

Both options work a treat and provides me with additional warning messages... Thank you so much for the detailed response

Regards

Roopen
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,488
Members
452,917
Latest member
MrsMSalt

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