Noob needing help on conditionally hiding rows based on condition of cells

pwnorcal

New Member
Joined
Mar 29, 2019
Messages
4
I have a complex spreadsheet which has a summary report. There are perhaps 200 populated rows on the summary, but for clarity I wish to set row height to hidden or 1 based on what is in the row. For example, in row 45 if cell B = " " I would like that row hidden or compressed. Row 46 may appear normally if there is something in cell B, then row 47 should be hidden if B = " " again.

The result obviously is a visible summary that may be only 30 rows high to look at, but actually there are maybe 170 rows reduced to 1 or 0 in height.

I have seen some if/then syntax which would seem to work, and it seems easy enough to copy such in one big VBA with each row named (such as 200 times) which is fine, but I cant get it to come together without error messages.

Can someone kindly show me the way for (say) 3-5 rows so I can mimic by copying and pasting for the longer command set I need to cover 200 rows? Help badly needed thank you thank you
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi & welcome to MrExcel
Is there anything in col B? such as a formula that returns "".
Or are the cells you want to hide totally empty?
 
Upvote 0
Hi & welcome to MrExcel
Is there anything in col B? such as a formula that returns "".
Or are the cells you want to hide totally empty?

It would be way easier for me if a formula returning " '' could be the target... Possible?
I can't tell you how much I appreciate your consideration of the issue.
 
Upvote 0
How about
Code:
Sub pwnorcal()
   Dim Cl As Range
   
   For Each Cl In Range("B2", Range("A" & Rows.Count).End(xlUp).Offset(, 1))
      If Cl.Value = " " Then
         Cl.EntireRow.Hidden = True
      Else
         Cl.EntireRow.Hidden = False
      End If
   Next Cl
End Sub
 
Upvote 0
How about
Code:
Sub pwnorcal()
   Dim Cl As Range
   
   For Each Cl In Range("B2", Range("A" & Rows.Count).End(xlUp).Offset(, 1))
      If Cl.Value = " " Then
         Cl.EntireRow.Hidden = True
      Else
         Cl.EntireRow.Hidden = False
      End If
   Next Cl
End Sub

Wonderful will experiment and report back!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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