Macro Hide/Print/Unhide rows w/ empty cell

andina4e

New Member
Joined
May 19, 2011
Messages
1
Hi Everyone,

I have this macro that is working perfectly, the only problem is that it takes very long time when a lot of rows are empty. I would like someone to help me modify it to make it faster.

I have a report with information form A3:P103, when a cell from column B3 is empty the entire row is hidden, then it prints the report, and unhide all rows again.

Here it is:

Sub Hide_rows_2()
Dim myCell As Range
Dim myRng As Range

With Worksheets("WORK HOURS REPORT")
Set myRng = .Range("B3", .Cells(.Rows.Count, "B").End(xlUp))
For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
myCell.EntireRow.Hidden = True
End If
Next myCell

.PrintOut

.UsedRange.Rows.Hidden = False
End With

End Sub

Thank you!

Andina4e
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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