Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-28-2022, 06:59 AM
Marcia's Avatar
Marcia Marcia is offline Message Box vba when a sheet is activated Windows 11 Message Box vba when a sheet is activated Office 2021
Expert
Message Box vba when a sheet is activated
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default Message Box vba when a sheet is activated

Hi. I copied this code from Ablebits that gives me the right message when Sheet X is selected. How do I add to the code that if Sheet X or Y or Z is selected, the same message box pops up?
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    On Error Resume Next
    If Sh.Name = "Sheet X" Then
        MsgBox "Print Form 2307", vbInformation, "Print 2307 Message"
    End If
End Sub
Thank you.

Last edited by Marcia; 09-28-2022 at 03:33 PM. Reason: typo
Reply With Quote
  #2  
Old 09-28-2022, 02:39 PM
rollis13's Avatar
rollis13 rollis13 is offline Message Box vba when a sheet is activated Windows 10 Message Box vba when a sheet is activated Office 2016
Competent Performer
 
Join Date: Jan 2021
Location: Cordenons
Posts: 140
rollis13 will become famous soon enough
Default

Since you have only three sheets to manage you could use:
Code:
If Sh.Name = "Sheet X" Or Sh.Name = "Sheet Y" Or Sh.Name = "Sheet Z" Then
Reply With Quote
  #3  
Old 09-28-2022, 03:31 PM
Marcia's Avatar
Marcia Marcia is offline Message Box vba when a sheet is activated Windows 11 Message Box vba when a sheet is activated Office 2021
Expert
Message Box vba when a sheet is activated
 
Join Date: May 2018
Location: Philippines
Posts: 526
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default

Thank you rollis. My error when trying to edit the code was I did not include the "Sh.Name".
Marcia
Reply With Quote
  #4  
Old 09-28-2022, 03:56 PM
rollis13's Avatar
rollis13 rollis13 is offline Message Box vba when a sheet is activated Windows 10 Message Box vba when a sheet is activated Office 2016
Competent Performer
 
Join Date: Jan 2021
Location: Cordenons
Posts: 140
rollis13 will become famous soon enough
Default

Glad having been of some help .
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove MS 365 that was not activated? junkcarp Office 3 04-29-2022 11:01 AM
This copy of MS Office not activated chzuck Office 1 10-10-2021 03:10 PM
Is my Office 'activated' or not? mabel Office 8 08-01-2019 04:18 AM
ActiveX is not activated when opening Excel2016 sheet Pierrot Excel Programming 0 10-28-2016 03:33 AM
Hyperlink not activated by footpedal Donone PowerPoint 2 05-05-2014 04:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:26 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft