If Coloum E, F, G, H are Blank need to Hide those entire Rows

sur

Board Regular
Joined
Jul 4, 2011
Messages
178
Hello All

I have a data where in i need to Hide the entire rows if the Coloum E, F, G, H are Blank or Zero.

Please help me with the VBA code

Thanks Regards
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
yes, if all the coloumn E, F, G, H are blank or else zero it should hide the entire row
 
Upvote 0
the sample data is like this in sheet1

Excel Workbook
ABCDEFGHIJ
1hdng1hdng2hdng3hdng4hdng5hdng6hdng7hdng8hdng9hdng10
2239831075568440572
3467573134841859837
445116638853212389836
54014783105513
69355308287258293960
790351974278967816021
84170379014512346855
96624652809193
103014485999496559452
1187953496129681593365
1248169994294939371
13623327707326
143610876384899893527
Sheet1


now try the macro test on this (undo will remove the hiding of rows and get back the original data)-to be on safe side keep a copy of sheet in sheet 2.


activate sheet1 and run "test"


Code:
Sub test()
Dim r As Range, filt As Range, j As Integer
Set r = Range("A1").CurrentRegion
For j = 5 To 8
 r.AutoFilter field:=j, Criteria1:=" ", Operator:=xlOr, Criteria2:=0
Next j
Set filt = r.Offset(1, 0).Resize(r.Rows.Count - 1, r.Columns.Count).SpecialCells(xlCellTypeVisible)
'MsgBox filt.Address

r.AutoFilter
filt.EntireRow.Hidden = True

End Sub

Code:
Sub undo()
Dim r As Range
Set r = Range("a1").CurrentRegion
r.Rows.Hidden = False
End Sub
Code:
 
Upvote 0
Thanks for the Reply

The data i have is 3 to 4 workbook merged into one excel workbook

so there is gap from one current region to another.

please help me to select all the rows in workbook and run the macro.
 
Upvote 0
use this statement and try

set r=activesheet.usedrange
add a msgbox
msgbox r.addres
(for checking)

the idea is somehow find the address of "lastcell"
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top