K
Kieranz
Hi All,
Using Excel2003 with WinXP. Still learning VBA...
Worksheet property has two names, one in brackets; call it CodeName
and the other without brackets call it TabName.
I have edited the CodeName to read "K1, K2, ... K10". Some sheets are
very hidden, others appear as needed when macro button is pressed. On
some sheets the user can rename the TabName. Thus some of my macros
will call on procedures to select and show appro. sheets and to very
hide others etc.
My codes:
Sub ShowShK2()
Dim ShCodeName as String
ShCodeName = "K2"
ShCodeName.Visible = xlSheetVisible '/ i get invalid qualifer error
'/ if i use the below i get subscript out of range error
Sheets(ShCodeName).Visible = xlSheetVisible
Call HideOtShs(ShCodeName)
'/ i get subscript out of range error on below
Application.Goto WorkSheet.ShCodeName.Range("A1"), True
'/ rename TabName
Worksheets(ShCodeName).Name = "Inc2"
End Sub
Sub HideOtShs(ShCodeName)
'/ always make sure there is 1 sht thats visible bef calling this sub
Dim oWkSh As Worksheet
For Each oWkSh In ThisWorkbook.Worksheets
If oWkSh.CodeName = ShCodeName Then
oWkSh.Visible = -1
Else
On Error Resume Next
oWkSh.Visible = 2
End If
Next oWkSh
End Sub
My understanding:
1. The CodeName cannot be programmatically changed; only by editing
thru the properties window. ie they must be prenamed or use default
name.
2. One sheet must be visible at all times.
3. Workbook protection must be off but worksheet protection can be on
to manipulate names and visible properties.
Help:
Not sure why i am getting the errors in my coding. Your help and
reasonings is much appreciated. God bless.
Rgds from Zambia "The Real Africa"
KZ
Using Excel2003 with WinXP. Still learning VBA...
Worksheet property has two names, one in brackets; call it CodeName
and the other without brackets call it TabName.
I have edited the CodeName to read "K1, K2, ... K10". Some sheets are
very hidden, others appear as needed when macro button is pressed. On
some sheets the user can rename the TabName. Thus some of my macros
will call on procedures to select and show appro. sheets and to very
hide others etc.
My codes:
Sub ShowShK2()
Dim ShCodeName as String
ShCodeName = "K2"
ShCodeName.Visible = xlSheetVisible '/ i get invalid qualifer error
'/ if i use the below i get subscript out of range error
Sheets(ShCodeName).Visible = xlSheetVisible
Call HideOtShs(ShCodeName)
'/ i get subscript out of range error on below
Application.Goto WorkSheet.ShCodeName.Range("A1"), True
'/ rename TabName
Worksheets(ShCodeName).Name = "Inc2"
End Sub
Sub HideOtShs(ShCodeName)
'/ always make sure there is 1 sht thats visible bef calling this sub
Dim oWkSh As Worksheet
For Each oWkSh In ThisWorkbook.Worksheets
If oWkSh.CodeName = ShCodeName Then
oWkSh.Visible = -1
Else
On Error Resume Next
oWkSh.Visible = 2
End If
Next oWkSh
End Sub
My understanding:
1. The CodeName cannot be programmatically changed; only by editing
thru the properties window. ie they must be prenamed or use default
name.
2. One sheet must be visible at all times.
3. Workbook protection must be off but worksheet protection can be on
to manipulate names and visible properties.
Help:
Not sure why i am getting the errors in my coding. Your help and
reasonings is much appreciated. God bless.
Rgds from Zambia "The Real Africa"
KZ