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
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Just so you know:

Your first page is considered 0
Your second page is considered 1


So in your case you need at least 5 pages
 
Upvote 0
So in your case your script should look like this:

Code:
Private Sub MultiPage1_Click(ByVal Index As Long)
'Modified  1/20/2019  7:36:16 AM  EST
With MultiPage1
    Select Case .Value
        Case 0, 1, 3: MsgBox "Hello"
    End Select
End With
End Sub
 
Upvote 0
Yeah I am aware of that .

Case 2 represents my third page
Case 4 represents my fifth page


So currently when I click on the page 3 or page 5 it says hello.

However, I want to stop the script from running when page 3 is active and I click it again.

Or when page 5 is active and I click it again.

Regards
 
Upvote 0
That's a hard one for me.
This is beyond my knowledgebase.
I will continue to monitor this thread to see what I can learn.
 
Upvote 0
As shown in my code, use Index instead of .Value in the Select Case
Code:
Private Sub MultiPage1_Click(ByVal Index As Long)
    With MultiPage1
        Select Case Index
            Case 2, 4
                'Do nothing for tabs 3 and 5
            Case Else
                MsgBox "Hello", Title:="Index = " & Index
        End Select
    End With
End Sub
 
Upvote 0
Yeah I am aware of that .

Case 2 represents my third page
Case 4 represents my fifth page


So currently when I click on the page 3 or page 5 it says hello.

However, I want to stop the script from running when page 3 is active and I click it again.

Or when page 5 is active and I click it again.

Regards

The script is not doing my request over here. Is there a way to achieve this?
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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