Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Hiding and Unhiding Sheets

Thanks for that quick response, however, it says i have a compile error
without for. What I am trying to do is to hide all the worksheets except one
called "Vendor Worksheet" after it runs another macro first. I want to
include this "fix" at the end of the macro. I understand now that I can't
hide all and I had the macro doing that and trying to make the Vendor
worksheet visible afterwards. That of course will not work.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Hiding and Unhiding Sheets

Hi Rob,

I have tried something out:

Sub HideShowAll(strSkip As String, blnShow As Boolean)
Dim sht As Worksheet


' Start error handling
On Local Error GoTo hideAll_err

' Activate the sheet that not must be hidden,
' if it does not exists an error occurs
If Not blnShow Then
Sheets(strSkip).Activate
End If

For Each sht In ThisWorkbook.Worksheets
If StrComp(sht.Name, strSkip, vbTextCompare) < 0 Then
sht.Visible = blnShow
End If
Next

' cancel error handling
On Local Error Resume Next

' Activate the wanted sheet,
' If if exists it is now visible

If blnShow Then
Sheets(strSkip).Activate
End If

Exit Sub
hideAll_err:
MsgBox "Sheet not found", vbCritical, strSkip

End Sub

You can use this separate Sub for Showing All and Hiding all but one.\

In the case ad hand you coud use
Call HideShowAll("Vendor Worksheet", False)

Hoop This Helps

Executor

  #3   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Hiding and Unhiding Sheets

Maybe I can be more explicit. I want to unhide the Vendor Worksheet only
(In this case it could be a Merchant Worksheet, Or a Procurement Worksheet)
I don't want to specify names of other worksheets that need to be hidden for
some may not be created as yet. I want to specify one sheet to be visible in
separate macros. So one macro would say unhide the Vendor Worksheet and hide
the rest. Another might say unhide the Merchant Worksheet and the Vendor
Worksheet and hide the rest.


"Executor" wrote:

Hi Rob,

I have tried something out:

Sub HideShowAll(strSkip As String, blnShow As Boolean)
Dim sht As Worksheet


' Start error handling
On Local Error GoTo hideAll_err

' Activate the sheet that not must be hidden,
' if it does not exists an error occurs
If Not blnShow Then
Sheets(strSkip).Activate
End If

For Each sht In ThisWorkbook.Worksheets
If StrComp(sht.Name, strSkip, vbTextCompare) < 0 Then
sht.Visible = blnShow
End If
Next

' cancel error handling
On Local Error Resume Next

' Activate the wanted sheet,
' If if exists it is now visible

If blnShow Then
Sheets(strSkip).Activate
End If

Exit Sub
hideAll_err:
MsgBox "Sheet not found", vbCritical, strSkip

End Sub

You can use this separate Sub for Showing All and Hiding all but one.\

In the case ad hand you coud use
Call HideShowAll("Vendor Worksheet", False)

Hoop This Helps

Executor


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
Hiding / Unhiding Sheets Larry Fitch Excel Discussion (Misc queries) 1 December 2nd 09 02:42 PM
Hiding and unhiding sheets D.Hay Excel Discussion (Misc queries) 2 December 10th 05 03:59 PM
Hiding/Unhiding multiple sheets in VBA? Simon Lloyd[_660_] Excel Programming 2 November 14th 05 10:57 AM
Hiding/Unhiding sheets and rows (An easy one for most of you....) Dean Goodmen Excel Programming 2 February 24th 05 11:06 PM
Hiding and Unhiding work sheets Frank[_19_] Excel Programming 3 November 19th 03 11:27 PM


All times are GMT +1. The time now is 10:44 PM.

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

About Us

"It's about Microsoft Excel"