VBA hiding blank rows

scoha

Active Member
Joined
Jun 15, 2005
Messages
428
I need a simple little bit of code to hide rows between two separate ranges in the same sheet:

Rows 10 to 90 and rows 100 to 200.

All it needs to do is check column B in between these ranges and if its blank then make the Entire.Row.Hidden=true


Anyone got some simple code to do this?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try...

Code:
[font=Verdana][color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] test()

    [color=darkblue]Dim[/color] Rng [color=darkblue]As[/color] Range
    [color=darkblue]Dim[/color] Area [color=darkblue]As[/color] Range
    [color=darkblue]Dim[/color] Cell [color=darkblue]As[/color] Range
    
    Application.ScreenUpdating = [color=darkblue]False[/color]

    [color=darkblue]Set[/color] Rng = Range("B10:B90,B100:B200")
    
    [color=darkblue]For[/color] [color=darkblue]Each[/color] Area [color=darkblue]In[/color] Rng.Areas
        [color=darkblue]For[/color] [color=darkblue]Each[/color] Cell [color=darkblue]In[/color] Area
            [color=darkblue]If[/color] Cell.Value = "" [color=darkblue]Then[/color] Cell.EntireRow.Hidden = [color=darkblue]True[/color]
        [color=darkblue]Next[/color] Cell
    [color=darkblue]Next[/color] Area
    
    Application.ScreenUpdating = [color=darkblue]True[/color]

[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
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