Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Macro-hide sub sheets?

Hi All.....

I create various maps, or diagrams in Excel. There are two major types,
"ORIGINAL", and "FUTURE". Each type has several support sheets to go with
it. I was wondering if it would be possible to create a macro that would
automatically expose to view, only those sheets (sheets C-H)associated with
the ORIGINAL sheet when I click on that one, and then hide those and expose
only those (sheets I-N) associated with the FUTURE sheet when I click on that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro-hide sub sheets?

this would be a start

Put this in the ThisWorkbook Module.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim b1 As Long, b2 As Long
Dim sht As Worksheet, sChr As String
Select Case LCase(Sh.Name)
Case "original"
b1 = xlSheetVisible
b2 = xlSheetHidden
Case "future"
b1 = xlSheetHidden
b2 = xlSheetVisible
Case Else
Exit Sub
End Select
For Each sht In Worksheets
sChr = UCase(sht.Name)
If Len(sChr) = 1 Then
If sChr = "C" And sChr <= "H" Then
sht.Visible = b1
ElseIf sChr = "I" And sChr <= "N" Then
sht.Visible = b2
End If
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.....

I create various maps, or diagrams in Excel. There are two major types,
"ORIGINAL", and "FUTURE". Each type has several support sheets to go

with
it. I was wondering if it would be possible to create a macro that would
automatically expose to view, only those sheets (sheets C-H)associated

with
the ORIGINAL sheet when I click on that one, and then hide those and

expose
only those (sheets I-N) associated with the FUTURE sheet when I click on

that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3




  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Macro-hide sub sheets?

Thanks a zillion Tom,..........as usual, your code works absolutely
perfect!!!

One additonal thing, if you please..............how could it be modified to
allow the 12 support sheets (now called C to H, and I to N) to have unique
text names instead of being "six letters in a row"?

Thanks again,
Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote in message
...
this would be a start

Put this in the ThisWorkbook Module.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim b1 As Long, b2 As Long
Dim sht As Worksheet, sChr As String
Select Case LCase(Sh.Name)
Case "original"
b1 = xlSheetVisible
b2 = xlSheetHidden
Case "future"
b1 = xlSheetHidden
b2 = xlSheetVisible
Case Else
Exit Sub
End Select
For Each sht In Worksheets
sChr = UCase(sht.Name)
If Len(sChr) = 1 Then
If sChr = "C" And sChr <= "H" Then
sht.Visible = b1
ElseIf sChr = "I" And sChr <= "N" Then
sht.Visible = b2
End If
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.....

I create various maps, or diagrams in Excel. There are two major types,
"ORIGINAL", and "FUTURE". Each type has several support sheets to go

with
it. I was wondering if it would be possible to create a macro that

would
automatically expose to view, only those sheets (sheets C-H)associated

with
the ORIGINAL sheet when I click on that one, and then hide those and

expose
only those (sheets I-N) associated with the FUTURE sheet when I click on

that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Macro-hide sub sheets?

Try another Select Case block, similar to the first one. Note that you can
write something like

Case "ABC", "JKL", "Sheet2", "Sheet1"


On Thu, 4 Nov 2004 19:42:11 -0500, "CLR" wrote:

Thanks a zillion Tom,..........as usual, your code works absolutely
perfect!!!

One additonal thing, if you please..............how could it be modified to
allow the 12 support sheets (now called C to H, and I to N) to have unique
text names instead of being "six letters in a row"?

Thanks again,
Vaya con Dios,
Chuck, CABGx3




"Tom Ogilvy" wrote in message
...
this would be a start

Put this in the ThisWorkbook Module.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim b1 As Long, b2 As Long
Dim sht As Worksheet, sChr As String
Select Case LCase(Sh.Name)
Case "original"
b1 = xlSheetVisible
b2 = xlSheetHidden
Case "future"
b1 = xlSheetHidden
b2 = xlSheetVisible
Case Else
Exit Sub
End Select
For Each sht In Worksheets
sChr = UCase(sht.Name)
If Len(sChr) = 1 Then
If sChr = "C" And sChr <= "H" Then
sht.Visible = b1
ElseIf sChr = "I" And sChr <= "N" Then
sht.Visible = b2
End If
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"CLR" wrote in message
...
Hi All.....

I create various maps, or diagrams in Excel. There are two major types,
"ORIGINAL", and "FUTURE". Each type has several support sheets to go

with
it. I was wondering if it would be possible to create a macro that

would
automatically expose to view, only those sheets (sheets C-H)associated

with
the ORIGINAL sheet when I click on that one, and then hide those and

expose
only those (sheets I-N) associated with the FUTURE sheet when I click on

that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3






  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro-hide sub sheets?

hi,
maybe not clickin on the sheet but you could add a custom
icon and assign a macro to it.
Sub machidesheets()
if sheets("sheets1")hidden = true then
Sheets("sheet1").unhide
Sheets("sheet2").hide
else
Sheets("sheet1").hide
Sheets("sheet2").unhide
end if
end sub
this code would unhide sheet1 and hide sheet2 if sheet1
was hidden or unhide sheet 2 and hide sheet1 if sheet1 was
not hidden.
you would have to add a line for each sheet you want to
hide or unhide.
regards

-----Original Message-----
Hi All.....

I create various maps, or diagrams in Excel. There are

two major types,
"ORIGINAL", and "FUTURE". Each type has several support

sheets to go with
it. I was wondering if it would be possible to create a

macro that would
automatically expose to view, only those sheets (sheets C-

H)associated with
the ORIGINAL sheet when I click on that one, and then

hide those and expose
only those (sheets I-N) associated with the FUTURE sheet

when I click on that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Macro-hide sub sheets?

Thanks very much for your response, I could also use something like this,
but I cannot seem to get it to work. I keep getting an error on the first
line.........and it comes up RED when viewing the code...........

if sheets("sheets1")hidden = true then


Vaya con Dios,
Chuck, CABGx3



wrote in message
...
hi,
maybe not clickin on the sheet but you could add a custom
icon and assign a macro to it.
Sub machidesheets()
if sheets("sheets1")hidden = true then
Sheets("sheet1").unhide
Sheets("sheet2").hide
else
Sheets("sheet1").hide
Sheets("sheet2").unhide
end if
end sub
this code would unhide sheet1 and hide sheet2 if sheet1
was hidden or unhide sheet 2 and hide sheet1 if sheet1 was
not hidden.
you would have to add a line for each sheet you want to
hide or unhide.
regards

-----Original Message-----
Hi All.....

I create various maps, or diagrams in Excel. There are

two major types,
"ORIGINAL", and "FUTURE". Each type has several support

sheets to go with
it. I was wondering if it would be possible to create a

macro that would
automatically expose to view, only those sheets (sheets C-

H)associated with
the ORIGINAL sheet when I click on that one, and then

hide those and expose
only those (sheets I-N) associated with the FUTURE sheet

when I click on that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3


.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Macro-hide sub sheets?

You need a period before Hidden, i.e.

if sheets("sheets1").hidden = true then

On Thu, 4 Nov 2004 20:05:39 -0500, "CLR" wrote:

Thanks very much for your response, I could also use something like this,
but I cannot seem to get it to work. I keep getting an error on the first
line.........and it comes up RED when viewing the code...........

if sheets("sheets1")hidden = true then


Vaya con Dios,
Chuck, CABGx3



wrote in message
...
hi,
maybe not clickin on the sheet but you could add a custom
icon and assign a macro to it.
Sub machidesheets()
if sheets("sheets1")hidden = true then
Sheets("sheet1").unhide
Sheets("sheet2").hide
else
Sheets("sheet1").hide
Sheets("sheet2").unhide
end if
end sub
this code would unhide sheet1 and hide sheet2 if sheet1
was hidden or unhide sheet 2 and hide sheet1 if sheet1 was
not hidden.
you would have to add a line for each sheet you want to
hide or unhide.
regards

-----Original Message-----
Hi All.....

I create various maps, or diagrams in Excel. There are

two major types,
"ORIGINAL", and "FUTURE". Each type has several support

sheets to go with
it. I was wondering if it would be possible to create a

macro that would
automatically expose to view, only those sheets (sheets C-

H)associated with
the ORIGINAL sheet when I click on that one, and then

hide those and expose
only those (sheets I-N) associated with the FUTURE sheet

when I click on that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3


.



  #8   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Macro-hide sub sheets?

Thanks Myrna...........I tried that already and it changed that line of code
form RED to BLACK, but I still couldn't get it to run. I tried changing the
sheet names also, still no luck.

Vaya con Dios,
Chuck, CABGx3



"Myrna Larson" wrote in message
...
You need a period before Hidden, i.e.

if sheets("sheets1").hidden = true then

On Thu, 4 Nov 2004 20:05:39 -0500, "CLR" wrote:

Thanks very much for your response, I could also use something like this,
but I cannot seem to get it to work. I keep getting an error on the

first
line.........and it comes up RED when viewing the code...........

if sheets("sheets1")hidden = true then


Vaya con Dios,
Chuck, CABGx3



wrote in message
...
hi,
maybe not clickin on the sheet but you could add a custom
icon and assign a macro to it.
Sub machidesheets()
if sheets("sheets1")hidden = true then
Sheets("sheet1").unhide
Sheets("sheet2").hide
else
Sheets("sheet1").hide
Sheets("sheet2").unhide
end if
end sub
this code would unhide sheet1 and hide sheet2 if sheet1
was hidden or unhide sheet 2 and hide sheet1 if sheet1 was
not hidden.
you would have to add a line for each sheet you want to
hide or unhide.
regards

-----Original Message-----
Hi All.....

I create various maps, or diagrams in Excel. There are
two major types,
"ORIGINAL", and "FUTURE". Each type has several support
sheets to go with
it. I was wondering if it would be possible to create a
macro that would
automatically expose to view, only those sheets (sheets C-
H)associated with
the ORIGINAL sheet when I click on that one, and then
hide those and expose
only those (sheets I-N) associated with the FUTURE sheet
when I click on that
one, and back and forth.

TIA for any ideas.....

Vaya con DIos,
Chuck, CABGx3


.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to hide sheets based upon cell value Joe M. Excel Discussion (Misc queries) 3 January 13th 10 07:05 PM
macro to hide sheets EricBB Excel Discussion (Misc queries) 5 August 10th 09 07:49 PM
Macro-Hide & Unhide Sheets with condition [email protected] Excel Discussion (Misc queries) 8 August 22nd 07 02:04 AM
If I have my sheets protected will that prevent me running a macro to hide certain sells? Marc Excel Worksheet Functions 0 May 17th 06 11:36 PM
macro to hide sheets ditchy Excel Discussion (Misc queries) 8 May 2nd 05 02:21 AM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"