is there a way to hide rows if there is a zero in certain cells.
ex
A
1 12
2 0
3 11
4 3
5 0
rows 2 amp; 5 would hide and unhide if any number higher than 0 is entered
later for those cells. The cells in column A are linked to another worksheet.
Hi not bright
You could try this:
Right-click the tab of your sheet, click View Code and paste:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Application.ScreenUpdating = False
For Each c In Range(quot;A2:Aquot; amp;
Cells.SpecialCells(xlCellTypeLastCell).Row) 'best method?
If c.Value = 0 Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next
Application.ScreenUpdating = True
End Sub
I'm not sure if the range finder is the best for you (it finds the last
row used in the entire sheet) and you may be better off substituting
Range(quot;A2:Aquot; amp; Cells.SpecialCells(xlCellTypeLastCell).Row)
with something like
Range(quot;A2:A100quot;) for whatever your actual range mght be.
Regards
SteveI've used things like this before, but don't really like it because once
it's hidden you have to manually unhide the rows to change the value. On
issues like this I generally try for a one-time solution. A change event
doesn't give you that flexibility.
--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAMgt; wrote in message oups.com...
gt; Hi not bright
gt;
gt; You could try this:
gt;
gt; Right-click the tab of your sheet, click View Code and paste:
gt;
gt; Private Sub Worksheet_Change(ByVal Target As Range)
gt; Dim c As Range
gt; Application.ScreenUpdating = False
gt; For Each c In Range(quot;A2:Aquot; amp;
gt; Cells.SpecialCells(xlCellTypeLastCell).Row) 'best method?
gt; If c.Value = 0 Then
gt; c.EntireRow.Hidden = True
gt; Else
gt; c.EntireRow.Hidden = False
gt; End If
gt; Next
gt; Application.ScreenUpdating = True
gt; End Sub
gt;
gt; I'm not sure if the range finder is the best for you (it finds the last
gt; row used in the entire sheet) and you may be better off substituting
gt;
gt; Range(quot;A2:Aquot; amp; Cells.SpecialCells(xlCellTypeLastCell).Row)
gt;
gt; with something like
gt;
gt; Range(quot;A2:A100quot;) for whatever your actual range mght be.
gt;
gt; Regards
gt;
gt; Steve
gt;
If the row is hidden when a value in the row is zero, how would you change
the zero value, which is hidden? With a macro, or is it a formula depending
on data outside the hidden rows?
quot;not brightquot; wrote:
gt; is there a way to hide rows if there is a zero in certain cells.
gt; ex
gt; A
gt; 1 12
gt; 2 0
gt; 3 11
gt; 4 3
gt; 5 0
gt;
gt; rows 2 amp; 5 would hide and unhide if any number higher than 0 is entered
gt; later for those cells. The cells in column A are linked to another worksheet.
example:
sheet3 c6 has =Sheet1!C16. Sheet1 C16 has nothing in it
Sheet3 Row6 would be hidden
If add a number to Sheet1 C16
Sheet3 Row6 would unhide
Is this possiblequot;Patricia Shannonquot; wrote:
gt; If the row is hidden when a value in the row is zero, how would you change
gt; the zero value, which is hidden? With a macro, or is it a formula depending
gt; on data outside the hidden rows?
gt;
gt; quot;not brightquot; wrote:
gt;
gt; gt; is there a way to hide rows if there is a zero in certain cells.
gt; gt; ex
gt; gt; A
gt; gt; 1 12
gt; gt; 2 0
gt; gt; 3 11
gt; gt; 4 3
gt; gt; 5 0
gt; gt;
gt; gt; rows 2 amp; 5 would hide and unhide if any number higher than 0 is entered
gt; gt; later for those cells. The cells in column A are linked to another worksheet.
I hoped it might be done with filters, but of course, if it were that easy,
someone with more knowledge than I would have already suggested that.
Since the data that is changing is on a different sheet than the place you
want to hide rows, you could do write a Worksheet_Activate macro for the
worksheet you want to hide/unhide the rows on.
quot;not brightquot; wrote:
gt; example:
gt; sheet3 c6 has =Sheet1!C16. Sheet1 C16 has nothing in it
gt; Sheet3 Row6 would be hidden
gt; If add a number to Sheet1 C16
gt; Sheet3 Row6 would unhide
gt;
gt; Is this possible
gt;
gt;
gt; quot;Patricia Shannonquot; wrote:
gt;
gt; gt; If the row is hidden when a value in the row is zero, how would you change
gt; gt; the zero value, which is hidden? With a macro, or is it a formula depending
gt; gt; on data outside the hidden rows?
gt; gt;
gt; gt; quot;not brightquot; wrote:
gt; gt;
gt; gt; gt; is there a way to hide rows if there is a zero in certain cells.
gt; gt; gt; ex
gt; gt; gt; A
gt; gt; gt; 1 12
gt; gt; gt; 2 0
gt; gt; gt; 3 11
gt; gt; gt; 4 3
gt; gt; gt; 5 0
gt; gt; gt;
gt; gt; gt; rows 2 amp; 5 would hide and unhide if any number higher than 0 is entered
gt; gt; gt; later for those cells. The cells in column A are linked to another worksheet.
- Jul 20 Thu 2006 20:08
Hiding rows
close
全站熱搜
留言列表
發表留言