LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default VBA code to hide blank rows

Hi,

Assuming is your below table:
A B
1 S.No Row
2 A 21
3 B 54
4 C
5 D 75
6 Total 150
7 A 21
8 B 54
9 C 45
10 D 120
11 Total 240
12 A
13 B
14 C
15 D
16 Total 0

Have a function on "M1" to pick the count of non blanks so that the range
for checking the condition is dynamic.. =COUNTA(A1:A29)

on Module 1 write the below code:

Sub Macro1()
X = Range("M1").Value
For I = 1 To X
Range("B" & I).Select
Y = Range("B" & I).Value
z = Range("A" & I).Value
If Y = "" Or (Y = 0 And z = "Total") Then
Rows(I & ":" & I).Select
Selection.EntireRow.Hidden = True
End If
Next I
End Sub

Hope this has solved your query.
Regards,
Stingz

"ub" wrote:

Hi
The data in my sheet is in the below mentioned format.

Column B
1 <Blank
2 <Blank
3 <Blank
4 <Blank
5 Total
6 2
7 4
8 6
9 <Blank
10 Total 12
I need to write a VBA code to hide rows that are blank and subsquently the
row that has field "Total"
Ex: Rows 1,2,3,4 are blank , so their "Total"-Row#5 is blank, so I need to
hide all these 5 rows.
In rows 6 to 10, row#9 is blank. So in this range, I need to hide only row # 9
I need to write a code that will satify both condition in a given range.

Please advise
Thanks



 
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
VB Code to hide and unhide rows Raj Excel Discussion (Misc queries) 2 February 27th 08 05:58 AM
Macro/code to hide rows Smatass Excel Worksheet Functions 1 September 25th 07 01:57 AM
Code for button to hide/unhide rows Chris Excel Worksheet Functions 5 March 5th 07 06:15 AM
Hide Blank Rows dee Excel Worksheet Functions 2 May 17th 06 11:30 PM
remove or hide blank rows Erik Beijlen via OfficeKB.com Excel Discussion (Misc queries) 1 February 1st 05 01:17 PM


All times are GMT +1. The time now is 08:19 PM.

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"