From: Bob on
I am trying to write a macro for use in Excel 2003 & 2007 that will toggle
between hiding (using xlVeryHidden) and unhiding a specific worksheet
(Sheet2).

I know how to perform a "normal" hide/unhide using the following code:

Sub HideUnhide()
Sheets("Sheet2").Visible = Not _
Sheets("Sheet2").Visible
End Sub

But I don't know how to incorporate xlVeryHidden. I would greatly
appreciate any help.

Thanks,
Bob

From: Tom Hutchins on
Try

Sub HideUnhide()
With Sheets("Sheet2")
If (.Visible = xlVeryHidden) Or (.Visible = False) Then
.Visible = True
Else
.Visible = xlVeryHidden
End If
End With
End Sub

Hope this helps,

Hutch

"Bob" wrote:

> I am trying to write a macro for use in Excel 2003 & 2007 that will toggle
> between hiding (using xlVeryHidden) and unhiding a specific worksheet
> (Sheet2).
>
> I know how to perform a "normal" hide/unhide using the following code:
>
> Sub HideUnhide()
> Sheets("Sheet2").Visible = Not _
> Sheets("Sheet2").Visible
> End Sub
>
> But I don't know how to incorporate xlVeryHidden. I would greatly
> appreciate any help.
>
> Thanks,
> Bob
>
From: Jacob Skaria on
Bob, try the below..

Sub HideUnhide()
Sheets("Sheet2").Visible = IIf(Sheets("Sheet2").Visible = _
True, xlSheetVeryHidden, True)
End Sub

--
Jacob (MVP - Excel)


"Bob" wrote:

> I am trying to write a macro for use in Excel 2003 & 2007 that will toggle
> between hiding (using xlVeryHidden) and unhiding a specific worksheet
> (Sheet2).
>
> I know how to perform a "normal" hide/unhide using the following code:
>
> Sub HideUnhide()
> Sheets("Sheet2").Visible = Not _
> Sheets("Sheet2").Visible
> End Sub
>
> But I don't know how to incorporate xlVeryHidden. I would greatly
> appreciate any help.
>
> Thanks,
> Bob
>
From: ozgrid.com on
Use the Sheet CodeName.

Sub HideUnhide()
'Use Sheet CodeName
'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
Sheet2.Visible = Not _
Sheet2.Visible = xlSheetVeryHidden
End Sub


--
Regards
Dave Hawley
www.ozgrid.com
"Jacob Skaria" <JacobSkaria(a)discussions.microsoft.com> wrote in message
news:7202285F-9280-4AE0-BBEA-24AFF74D3787(a)microsoft.com...
> Bob, try the below..
>
> Sub HideUnhide()
> Sheets("Sheet2").Visible = IIf(Sheets("Sheet2").Visible = _
> True, xlSheetVeryHidden, True)
> End Sub
>
> --
> Jacob (MVP - Excel)
>
>
> "Bob" wrote:
>
>> I am trying to write a macro for use in Excel 2003 & 2007 that will
>> toggle
>> between hiding (using xlVeryHidden) and unhiding a specific worksheet
>> (Sheet2).
>>
>> I know how to perform a "normal" hide/unhide using the following code:
>>
>> Sub HideUnhide()
>> Sheets("Sheet2").Visible = Not _
>> Sheets("Sheet2").Visible
>> End Sub
>>
>> But I don't know how to incorporate xlVeryHidden. I would greatly
>> appreciate any help.
>>
>> Thanks,
>> Bob
>>

From: Jacob Skaria on
Dave, how does that toggle between xlSheetVERYHidden and xlSheetVisible?

--
Jacob (MVP - Excel)


"ozgrid.com" wrote:

> Use the Sheet CodeName.
>
> Sub HideUnhide()
> 'Use Sheet CodeName
> 'http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm
> Sheet2.Visible = Not _
> Sheet2.Visible = xlSheetVeryHidden
> End Sub
>
>
> --
> Regards
> Dave Hawley
> www.ozgrid.com
> "Jacob Skaria" <JacobSkaria(a)discussions.microsoft.com> wrote in message
> news:7202285F-9280-4AE0-BBEA-24AFF74D3787(a)microsoft.com...
> > Bob, try the below..
> >
> > Sub HideUnhide()
> > Sheets("Sheet2").Visible = IIf(Sheets("Sheet2").Visible = _
> > True, xlSheetVeryHidden, True)
> > End Sub
> >
> > --
> > Jacob (MVP - Excel)
> >
> >
> > "Bob" wrote:
> >
> >> I am trying to write a macro for use in Excel 2003 & 2007 that will
> >> toggle
> >> between hiding (using xlVeryHidden) and unhiding a specific worksheet
> >> (Sheet2).
> >>
> >> I know how to perform a "normal" hide/unhide using the following code:
> >>
> >> Sub HideUnhide()
> >> Sheets("Sheet2").Visible = Not _
> >> Sheets("Sheet2").Visible
> >> End Sub
> >>
> >> But I don't know how to incorporate xlVeryHidden. I would greatly
> >> appreciate any help.
> >>
> >> Thanks,
> >> Bob
> >>
>