> Sorry for the poor explanation. I have have modified the code to what I
> thought would work. It should be more more helpful in understanding. Except
[quoted text clipped - 255 lines]
> >
> > Dave Peterson
Thanks, that is amazing the was case works that way and that you can have
multiple lines after the Case statement. I would have never guessed. It
works great.
The last thing that needs modification is to change the code for the
wks1Name = to use sheet4 (no quotes) instead of "Tour1". I tried this by
modifying the code so the
wks1Name.Visible = xlSheetVisible would be converted to the syntax upon
execution to sheet4.Visible = xlSheetvisible but got the follow error.
Compile error:
Invalid qualifier
I click on help so I wouldn't bother you again and the following came up
Invalid qualifier
Qualifiers are used for disambiguation. This error has the following cause
and solution:
The qualifier does not identify a project, module, object, or a variable of
user-defined type within the current scope.
Check the spelling of the qualifier. Make sure that the qualifying
identifier is within the current scope. For example, a variable of
user-defined type in a Private module is visible only within that module.
I tried several thing but they didn't work.
Here is the modified code.
Option Explicit
Sub testme()
Dim myCBX As CheckBox
Dim wks1Name As String
Dim wks2Name As String
Dim wkbkPwd As String
wkbkPwd = "hi"
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)
wks1Name = ""
wks2Name = ""
Select Case LCase(myCBX.Name)
Case Is = LCase("check box 140")
wks1Name = Sheet4 'Original sheet name not renamed sheet name
Tour1
wks2Name = Sheet40 '... Tour1 Data
Case Is = LCase("check box 141")
wks1Name = Sheet5 '... Tour2
wks2Name = Sheet41 '.Tour2 Data
End Select
If wks1Name = "" Then
MsgBox "Design error--no sheet assigned to this checkbox"
Exit Sub
End If
'unprotect the workbook
With ThisWorkbook
Application.ScreenUpdating = False
'.Unprotect Password:=wkbkPwd
If myCBX.Value = xlOn Then
wks1Name.Visible = xlSheetVisible
wks2Name.Visible = xlSheetVisible
Else
wks1Name.Visible = xlSheetHidden
wks2Name.Visible = xlSheetHidden
End If
'.Protect Password:=wkbkPwd, structure:=True, Windows:=False
End With
End Sub
> Instead of two separate cases (once the first is satisfied, the second
> (and
[quoted text clipped - 293 lines]
>> >
>> > Dave Peterson
Dave Peterson - 27 Jan 2008 21:29 GMT
If you go to the VBE and hit ctrl-r to see the project explorer.
Select your project and expand all those levels--including the worksheets.'
You'll see things like:
Sheet1(Tour1)
Sheet2(Tour1 Data)
Sheet3(Tour2)
...
The name inside ()'s is the name the user sees. The name in front of that is
called the code name and it should be much more difficult for the user to change
this.
Maybe you could incorporate those code names into your code:
Option Explicit
Sub testme2()
Dim mySheet As Worksheet
Dim myName As String
Dim wks As Worksheet
myName = "hi"
Set mySheet = Nothing
Select Case LCase(myName)
Case Is = "hi"
Set mySheet = Sheet1
Case Is = "bye"
Set mySheet = Sheet2
End Select
If mySheet Is Nothing Then
'something bad happened
Else
mySheet.Visible = xlSheetHidden
End If
End Sub
> Thanks, that is amazing the was case works that way and that you can have
> multiple lines after the Case statement. I would have never guessed. It
[quoted text clipped - 371 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Breck - 27 Jan 2008 22:32 GMT
Thank you Dave for all of you help and time.
Everything is working perfectly. I have learned so much from you. I was
writing 16 different macros, now I have one. I've learning the amazing
capabilities of case and that it can handle more that one line. I now better
understand that the reason that my last code didn't work and how to
incorporate the code name into many of the functions that start with
worksheet. You have been so helpful and generous with your knowledge.
> If you go to the VBE and hit ctrl-r to see the project explorer.
>
[quoted text clipped - 446 lines]
>> >
>> > Dave Peterson
Dave Peterson - 27 Jan 2008 23:10 GMT
I'm still confused over what you wanted <vbg>, but it sounds like you're off and
running!
Good luck.
> Thank you Dave for all of you help and time.
>
[quoted text clipped - 459 lines]
> >
> > Dave Peterson

Signature
Dave Peterson