Force Msg Box on sheet selection

Ryan1996

Board Regular
Joined
Jun 4, 2018
Messages
55
Is there anyway i can force a msg box to appear when a specific sheet is selected? Is it also possible to include to option to run a specific macro from that box that appears too?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Yes and Yes:

We need exact details.

Like when what sheet or sheets are activated.
And run what script.
And what should the Message Box say?

Exact details will always help getting you a quick answer.
 
Last edited:
Upvote 0
I can adjust macro's. Just needed to know if possible and how.

When "Detailed assessment criteria" is activated

run macro "Scope_Removal"

Code:
Sub scope_removal()

Worksheets("Detailed assessment Criteria").Activate


Dim rng As Range, cell As Range
    Set rng = Range("G2:G1000")
        For Each cell In rng
        If cell = "No" Then cell.EntireRow.Hidden = True Else cell.EntireRow.Hidden = False
    Next cell
End Sub


Sub DefaultMsgBox()
MsgBox "Would you like to check that all out of scope controls are removed?"
End Sub

Yes = run macro then confirm macro has been run via message box.
No = Nothing, close message box.
 
Upvote 0
I asked the question because I thought you meant more then one sheet.
If you want something to happen when you activate 10 different sheets we would need to know what the script looks like.

We could say for example if sheet name is "Me" then Msgbox "Me" for example.
But when you say:
I can adjust macro's. Just needed to know if possible and how.

I'm not sure what to say.

Like is the script going to be the same for all sheets or always different.

If always different then you would have to use a script like this:
And each one may be different:

Right click on the sheet tab choose View code and put in this code.


Code:
Private Sub Worksheet_Activate()
'Modified  4/16/2019  9:56:14 AM  EDT
Cells(1, 1).Value = ActiveSheet.Name
End Sub


 
Upvote 0
If you wanted the same scipt to run in all sheets or a selected number of sheets you can use a script like this:

So you do not have to put a sheet activate script in all 10 or so of your sheet.

To install this script right click on any sheet tab.
Double click on "ThisWorkbook"

And enter this code:

Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'Modified  4/16/2019  10:06:35 AM  EDT
MsgBox "Hello You just activated sheet named  " & ActiveSheet.Name
End Sub
 
Upvote 0
The code you provided is just to activate said sheet/s.

I need the code for when that sheet (The one i mentioned) is clicked a message box will automatically pop up with the text (Mentioned above) and two options (Mentioned above)
 
Upvote 0
Did it myself..

Code:
Private Sub Worksheet_Activate()Cells(1, 1).Value = ActiveSheet.Name
Dim Answer As String
Dim MyNote As String
 
    MyNote = "Would you like to check controls have been removed?"
    Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")
    
If Answer = vbNo Then
        
    Else
        Call scope_removal
        MsgBox "Controls have been checked!"
    End If
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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