Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hide All Worksheets Except Specific

I know how to hide worksheets using VBA but I am unsure how to hide all
the worksheets in a workbook except for a specific one. The name of
this worksheet will never change. Any ideas? I would appreciate any
help.


Thank you,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Hide All Worksheets Except Specific

dim ws as Worksheet
for each ws in Worksheets
if ws.name<"Sheet1" then
ws.Hide
end if
nxt ws

HTH
--
AP

"Kris" a écrit dans le message de news:
...
I know how to hide worksheets using VBA but I am unsure how to hide all
the worksheets in a workbook except for a specific one. The name of
this worksheet will never change. Any ideas? I would appreciate any
help.


Thank you,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Hide All Worksheets Except Specific

for each ws in worksheets
if ws.name<"myname" then ...........
next ws

--
Don Guillett
SalesAid Software

"Kris" wrote in message
oups.com...
I know how to hide worksheets using VBA but I am unsure how to hide all
the worksheets in a workbook except for a specific one. The name of
this worksheet will never change. Any ideas? I would appreciate any
help.


Thank you,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hide All Worksheets Except Specific

I have tried to modify this so it hides all but Sheet1 however it is
not working. Any advice?
Sub Hide()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name < ("Sheet1") Then
Else
ws.Hide
End If
nxt ws

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Hide All Worksheets Except Specific

sub hidebut()
for each ws in worksheets
if ws.name<"Sheet1" then ws.Visible = False
next ws
end sub
--
Don Guillett
SalesAid Software

"Kris" wrote in message
oups.com...
I have tried to modify this so it hides all but Sheet1 however it is
not working. Any advice?
Sub Hide()
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Name < ("Sheet1") Then
Else
ws.Hide
End If
nxt ws

End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hide All Worksheets Except Specific

This still doesn't help me as I have macro's that will do Sheet A - Z
depending on certain variables and then Sheet1. I want to hide all
Sheets a-z (Currently I have SheetA - Sheet D but tomorrow the Macro
could add SheetE and I don't want to have to modify the code just
because it added a sheet.)

Thanks for the continued help.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Hide All Worksheets Except Specific

The suggested code by Ardus and Don do exactly that. They hide all sheets
except a sheet named Sheet1 regardless of how many other sheets there are.
the suggested code needed no adjustment. Your ill-advised adjustment to
Ardus' code insured it would not work. In fact you changed it so only sheet1
would be hidden.

--
Regards,
Tom Ogilvy



"Kris" wrote:

This still doesn't help me as I have macro's that will do Sheet A - Z
depending on certain variables and then Sheet1. I want to hide all
Sheets a-z (Currently I have SheetA - Sheet D but tomorrow the Macro
could add SheetE and I don't want to have to modify the code just
because it added a sheet.)

Thanks for the continued help.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hide All Worksheets Except Specific

I don't know why I wasn't understanding, I am just thick. I was looking
for the does not equal operator trying != and all sorts of wild things.
< is does not equal. Wow I am slow.


Thanks everyone for the help.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Hide All Worksheets Except Specific

I am having some syntax issue trying to modify this script now. I am
missing something completly obvious can one of you help. (The reasoning
behind this is that when closing the workbook it will save itself twice
each time it saves different sheets will be hidden so that when people
open each workbook only the information they need will be shown.) Here
is my code.

Sub hidebut()
For Each ws In Worksheets
If Active.Workbook = "abefrof.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = True
Next ws

If Active.Workbook = "abetest1.xls" Then
If ws.Name < "Solution Direct Tracking" Then ws.Visible = False
Next ws

End Sub

Thanks for all the help

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
Hide a specific number in a cell Rhondarp Excel Discussion (Misc queries) 6 May 26th 06 08:24 PM
hide specific cells in Excel Espo Excel Worksheet Functions 1 May 25th 06 03:12 PM
print specific worksheets in specific order. jarvo Excel Programming 1 April 11th 06 11:05 AM
Hide all rows where one specific cell in that row = 0? jaydevil Excel Discussion (Misc queries) 2 August 26th 05 02:48 PM
hide rows with specific contents Dennis Cheung[_2_] Excel Programming 2 May 12th 05 06:22 AM


All times are GMT +1. The time now is 05:16 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"