route217
asked on
Add two more worksheet to current code...
Hi Experts
i need to add the following worksheet to function with the vba code below...
1. Payment
2. Telephony...
i need to add the following worksheet to function with the vba code below...
1. Payment
2. Telephony...
Sub ToggleVisibilityOfDataWs()
Application.EnableEvents = False
Const MasterName As String = "Main"
Const pw As String = "Test1"
With ThisWorkbook
If .ActiveSheet.Name = "Main" Then
With .Worksheets("Source Data")
If .Visible Then
.Visible = False
Else
If InputBox("PLEASE ENTER PASSWORD:", "Password Security Check....") = pw Then
.Visible = True
Else
MsgBox "INCORRECT PASSWORD - PLEASE TRY AGAIN!", vbOKOnly + vbInformation, "Feedback....."
End If
End If
End With
Else
MsgBox "Can only run this macro from worksheet called " & MasterName, vbOKOnly + vbInformation, "Feedback....."
End If
End With
Application.EnableEvents = True
ActiveWindow.DisplayWorkbookTabs = True
End Sub
ASKER
worksheet name in above question...
payments and telephony
and yes to the second part. ..
payments and telephony
and yes to the second part. ..
One way is this:
Another way is
If .ActiveSheet.Name = "Main" Or _
.ActiveSheet.Name = "Payment" Or _
.ActiveSheet.Name = "Telephony" Then
Another way is
Select Case .ActiveSheet.Name
Case "Main", "Payment", "Telephony"
' do your code
Case Else
' your error message
End Select
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Martinliss
firsty..Thanks for the feedback...but new to this and apologies if this sound rude....but what's the complete code...kindly
firsty..Thanks for the feedback...but new to this and apologies if this sound rude....but what's the complete code...kindly
ASKER
thanks shanan212
what can I say...
what can I say...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also change line 5 to
Const MasterName As String = "Main or Payment or Telephony"
Const MasterName As String = "Main or Payment or Telephony"
I'm glad I was able to help.
Marty - MVP 2009 to 2013
Marty - MVP 2009 to 2013
And
Do you want the new worksheets to be visible if the password is correct?