Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Hiding/Unhiding sheets and rows (An easy one for most of you....)

I have three sheets in my workbook and under certain circumstance I
need to hide/unhide and entire sheet, or just certain rows. Could some
one give me an example on how to code a line to do this?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Hiding/Unhiding sheets and rows (An easy one for most of you....)

This hide's a sheet if OK is pressed:

Sub HideSheet()
Dim hideit
hideit = MsgBox("Press OK to hide", vbOKCancel, "Hide Test")

If hideit = 1 Then
Worksheets("Sheet1").Visible = False
Else
Worksheets("Sheet1").Visible = True
End If
End Sub



This does the same with Column C

Sub HideCol()
Dim hideit
hideit = MsgBox("Press OK to hide", vbOKCancel, "Hide Test")

If hideit = 1 Then
Columns("C:C").EntireColumn.Hidden = True
Else
Columns("C:C").EntireColumn.Hidden = False
End If

End Sub

HTH
Steve




"Dean Goodmen" wrote in message
...
I have three sheets in my workbook and under certain circumstance I
need to hide/unhide and entire sheet, or just certain rows. Could some
one give me an example on how to code a line to do this?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Hiding/Unhiding sheets and rows (An easy one for most of you....)

add this to the code for sheet1.make sure that you have a worksheet called
sheet2

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
If Target.Value = 0 Then
SheetHide "Sheet2"
Else
SheetUnhide "Sheet2"
End If
End If
End Sub

Sub SheetHide(sheetname As String)
Worksheets(sheetname).Visible = False
End Sub
Sub SheetUnhide(sheetname As String)
Worksheets(sheetname).Visible = True
End Sub

type 0 (zero) into A1 of sheet1 and sheet2 will be hidden. type anything
else into A1 of sheet1 and sheet2 will be visible

TIP: Use the macro-recorder & examine the code - it will be a big help.
Usually the code will need to be tweaked to get it just so though.

HTH

Patrick Molloy
Microsoft Excel MVP





"Dean Goodmen" wrote:

I have three sheets in my workbook and under certain circumstance I
need to hide/unhide and entire sheet, or just certain rows. Could some
one give me an example on how to code a line to do this?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Hiding/Unhiding sheets and rows (An easy one for most of you....)

That works great; however how would you hide multiple rows, or a range
of them?

I tried Rows("2:5").Entirerow.Hidden = True, but it did not work...


On Tue, 22 Feb 2005 18:30:44 +1100, "Steve"
wrote:

This hide's a sheet if OK is pressed:

Sub HideSheet()
Dim hideit
hideit = MsgBox("Press OK to hide", vbOKCancel, "Hide Test")

If hideit = 1 Then
Worksheets("Sheet1").Visible = False
Else
Worksheets("Sheet1").Visible = True
End If
End Sub



This does the same with Column C

Sub HideCol()
Dim hideit
hideit = MsgBox("Press OK to hide", vbOKCancel, "Hide Test")

If hideit = 1 Then
Columns("C:C").EntireColumn.Hidden = True
Else
Columns("C:C").EntireColumn.Hidden = False
End If

End Sub

HTH
Steve




"Dean Goodmen" wrote in message
.. .
I have three sheets in my workbook and under certain circumstance I
need to hide/unhide and entire sheet, or just certain rows. Could some
one give me an example on how to code a line to do this?

Thanks!



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
need code for hiding/unhiding sheets using checkboxes pzx8hf Excel Worksheet Functions 1 August 13th 08 12:11 AM
unhiding and hiding rows Paul_of_Abingdon[_2_] Excel Discussion (Misc queries) 2 March 6th 08 03:22 PM
Hiding and unhiding sheets D.Hay Excel Discussion (Misc queries) 2 December 10th 05 03:59 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 06:50 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"