VBA to hide row if cell is blank given a pre selected range of rows

joecom88

New Member
Joined
Nov 13, 2014
Messages
3
I am looking to hide rows if column B is blank using a pre-selected range of rows.

I have several data blocks on a sheet that feed charts and as I copy/paste data into it, I select the range of rows then I plan on running this module using the pre-selected range (so I don't have to make a dozen specific hide modules) to hide empty rows.

I'm using RowDdx and I can't quite get the variables to work with it.

Greatly appreciate any help.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Have you tried a worksheet_Change event on the target sheet to trigger your macro?

Here's a rough example:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Row As Integer
Set Rng = Intersect(Target, Range("A:A"))
If Not Rng Is Nothing Then  [COLOR=#008000] 'two ranges intersect[/COLOR]
    Row = Right(Rng.Address, Len(Rng.Address) - 3)
   [COLOR=#008000] 'test to see if data is blank[/COLOR]
    If Range("A" & Row).Value = "" Then
        Rows(Row).Hidden = True
    Else
        Rows(Row).Hidden = False
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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