VB Code to hide and unhide rows

R

Raj

Dear All

I need a VB code for the following.

When I select a range in an excel sheet. The hidden rows in that range
should get unhidden and then based on a condition the rows must be hidden
within the selected range.

For example I select A1 to D5. Whatever hidden rows are there between Row 1
and Row 5 should get hidden. Then if it is observed that between A1:D1 all
the cells are blank, then the code hides row 1 and so on.

I need the same very urgently as my work is pending just because of this code.

Thanks a lot in Advance
Raj
 
B

Bernie Deitrick

Raj,

Dim myC As Range
Selection.EntireRow.Hidden = False
For Each myC In Selection.Rows
If Application.WorksheetFunction.CountBlank(myC) = _
Selection.Columns.Count Then
myC.EntireRow.Hidden = True
End If
Next myC

HTH,
Bernie
MS Excel MVP
 
R

Raj

Thanks a lot

It works wonders

Regards
Raj

Bernie Deitrick said:
Raj,

Dim myC As Range
Selection.EntireRow.Hidden = False
For Each myC In Selection.Rows
If Application.WorksheetFunction.CountBlank(myC) = _
Selection.Columns.Count Then
myC.EntireRow.Hidden = True
End If
Next myC

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top