Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Hide Rows based on value of a cell

Hi...

If I enter 1 into cell A1 I want to automatically hide rows 8-19. Is this
possible?

Cheers

G
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Hide Rows based on value of a cell

Gordon,

Right click your sheet tab, view code and paste this in.
Enter 1 in A1 hides the rows anything else makes them visible,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value = 1 Then
Rows("8:19").EntireRow.Hidden = True
Else
Rows("8:19").EntireRow.Hidden = False
End If
Application.EnableEvents = True
End If
End Sub

Mike

"Gordon" wrote:

Hi...

If I enter 1 into cell A1 I want to automatically hide rows 8-19. Is this
possible?

Cheers

G

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Hide Rows based on value of a cell

Hi...

The value 1 fires in cell a1 and nothing happens. I should add that the 1 is
derived from a formula, does that make a difference.

This is the code currently in the sheet properties. Might something clash?

Private Sub Worksheet_Activate()
ActiveSheet.ScrollArea = "$a$1:$s$30"
End Sub
Private Sub Worksheet_Calculate()
Dim sh As Worksheet
SheetArray = Array("R", "A", "B", "Ba", "Rs", "Co", _
"Bf", "Bs", "Pa", "Pt", "Pa", "Ea", "Bar", "Ds", "Sp", "df")
Set sh = Worksheets("SETUP")
For sht = LBound(SheetArray) To UBound(SheetArray)
With Sheets(SheetArray(sht))
If sh.Range("R4").Value = 0 Then
.Visible = xlSheetHidden
ElseIf sh.Range("R4").Value = 1 Then
.Visible = xlSheetVisible
End If
End With
Next
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value = 0 Then
Rows("1:19").EntireRow.Hidden = True
Else
Rows("1:19").EntireRow.Hidden = False
End If
Application.EnableEvents = True
End If
End Sub



"Mike H" wrote:

Gordon,

Right click your sheet tab, view code and paste this in.
Enter 1 in A1 hides the rows anything else makes them visible,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value = 1 Then
Rows("8:19").EntireRow.Hidden = True
Else
Rows("8:19").EntireRow.Hidden = False
End If
Application.EnableEvents = True
End If
End Sub

Mike

"Gordon" wrote:

Hi...

If I enter 1 into cell A1 I want to automatically hide rows 8-19. Is this
possible?

Cheers

G

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 Rows Based on Cell Result BJ Excel Programming 2 April 14th 08 11:41 PM
hide rows based on cell value dummster New Users to Excel 1 February 15th 06 11:37 PM
hide rows based on value in cell dummster Excel Discussion (Misc queries) 0 February 15th 06 03:27 PM
Macro to hide rows based on a zero value in a particular cell Peter Excel Programming 2 July 29th 04 03:19 AM
How to Hide Rows based on conditional value in cell Nick Excel Programming 1 May 21st 04 11:16 AM


All times are GMT +1. The time now is 02:20 AM.

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"