Macro to delete a selected range of blank cells

rbcarver

New Member
Joined
Oct 13, 2002
Messages
31
I need to devise a macro that will hide only certain cells (cells could have a unique attribute?) - when they are blank. The users of this spreadsheet will select required fields with check boxes then run a macro to hide cells that are blank (when a field is not selected a group of cells will be left blank). This one left me bewildered!
Thanks,
Ryan
 
A couple of questions....when you say "hide" do you mean remove them form the screen or mark the contents invisible to the viewer? Are the cells scattered throught the worksheet or are they blank full rows or columns?

pll
 
Upvote 0
I already have an if statement that hides the contents from the viewer with "" I need a macro that will hide rows among a selected range of cells that are blank or ""'d. Hope that makes sense
 
Upvote 0
Hi,

something like this:
<pre>
Sub hiderows()
Dim u As Range
Dim cl As Range
For Each cl In Selection
If cl.Value = "" Then
If u Is Nothing Then
Set u = cl
Else
Set u = Union(u, cl)
End If
End If
Next
If Not u Is Nothing Then u.EntireRow.Hidden = True
End Sub
</pre>
 
Upvote 0

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