Don't run script when active page is clicked

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
If the active page is page3 or page5, then don't say hello when it's clicked.

It's giving me a headache. Can someone fix that for me?

Code:
Private Sub MultiPage1_Click (ByVal Index As Long )
With MultiPage1
Select Case .Value 
    Case 2, 4 : MsgBox "Hello"
End Select 
End With
End Sub
 
Code:
Private Sub MultiPage1_Click(ByVal Index As Long)
    Static LastPage As Long
    If MultiPage1.Value = 2 Then
        If LastPage <> 2 Then MsgBox "hi"
    ElseIf MultiPage1.Value = 4 then
        If LastPage <> 4 Then MsgBox "hi"
    End If
    LastPage = MultiPage1.Value
End Sub

Sure, this is also cute.

Regards
Kelly
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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