Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
tamato43
 
Posts: n/a
Default Conditionally Hide Rows

Hello everyone,

This is my second posting.

Does anyone know a VBA script to conditionally hide selected rows if they
equal zero or are left blank?

Please help.
  #2   Report Post  
David McRitchie
 
Posts: n/a
Default

Use a formula on the worksheet to provide a null value or an "X" and then
filter on that column. Data, Filter

You could use advanced filter and include the formula.

More information on Filters:
http://www.contextures.com/tiptech.html
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"tamato43" wrote in message ...
Hello everyone,

This is my second posting.

Does anyone know a VBA script to conditionally hide selected rows if they
equal zero or are left blank?

Please help.



  #3   Report Post  
Gord Dibben
 
Posts: n/a
Default

Entire rows are 0 or blank?

Sub DeleteEmptyRows()
Dim LastRow As Long
''only if entire row is blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

Just rows with a certain column's cells blank or zero?

Sub HideBlank_Zeros_Rows()
'using set column
Dim RngCol As Range
Dim i As Range
Set RngCol = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
For Each i In RngCol
If i.Value = "" Or i.Value = "0" Then _
i.EntireRow.Hidden = True
Next i
End Sub


Gord Dibben Excel MVP

On Tue, 10 May 2005 13:48:12 -0700, "tamato43"
wrote:

Hello everyone,

This is my second posting.

Does anyone know a VBA script to conditionally hide selected rows if they
equal zero or are left blank?

Please help.


  #4   Report Post  
tamato43
 
Posts: n/a
Default

Thanks Gord this helps, but is there a way to hide instead of deleting?

"Gord Dibben" wrote:

Entire rows are 0 or blank?

Sub DeleteEmptyRows()
Dim LastRow As Long
''only if entire row is blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

Just rows with a certain column's cells blank or zero?

Sub HideBlank_Zeros_Rows()
'using set column
Dim RngCol As Range
Dim i As Range
Set RngCol = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
For Each i In RngCol
If i.Value = "" Or i.Value = "0" Then _
i.EntireRow.Hidden = True
Next i
End Sub


Gord Dibben Excel MVP

On Tue, 10 May 2005 13:48:12 -0700, "tamato43"
wrote:

Hello everyone,

This is my second posting.

Does anyone know a VBA script to conditionally hide selected rows if they
equal zero or are left blank?

Please help.



  #5   Report Post  
Gord Dibben
 
Posts: n/a
Default

Sorry about that tam!

Change the .delete line to entirerow.hidden = true

Sub DeleteEmptyRows()
Dim LastRow As Long
''only if entire row is blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then _
Rows(r).EntireRow.Hidden = True
Next r
End Sub


Gord


On Wed, 11 May 2005 06:02:06 -0700, "tamato43"
wrote:

Thanks Gord this helps, but is there a way to hide instead of deleting?

"Gord Dibben" wrote:

Entire rows are 0 or blank?

Sub DeleteEmptyRows()
Dim LastRow As Long
''only if entire row is blank
LastRow = ActiveSheet.UsedRange.Row - 1 + _
ActiveSheet.UsedRange.Rows.Count
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

Just rows with a certain column's cells blank or zero?

Sub HideBlank_Zeros_Rows()
'using set column
Dim RngCol As Range
Dim i As Range
Set RngCol = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
For Each i In RngCol
If i.Value = "" Or i.Value = "0" Then _
i.EntireRow.Hidden = True
Next i
End Sub


Gord Dibben Excel MVP

On Tue, 10 May 2005 13:48:12 -0700, "tamato43"
wrote:

Hello everyone,

This is my second posting.

Does anyone know a VBA script to conditionally hide selected rows if they
equal zero or are left blank?

Please help.




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
can you hide rows with a formula? david Excel Discussion (Misc queries) 2 April 8th 05 03:21 PM
Hide Rows Steve Excel Discussion (Misc queries) 2 February 9th 05 10:09 PM
how to hide rows in a protected sheet Prakash Excel Worksheet Functions 7 January 18th 05 02:42 PM
Checkbox to hide and unhide rows Please. Steved Excel Worksheet Functions 2 December 6th 04 11:30 PM
Excel - if cells = 0, how to conditionally hide rows in chart fineimage Excel Worksheet Functions 1 November 11th 04 09:45 PM


All times are GMT +1. The time now is 03:26 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"