How do you hide multiple row macro

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

Hi,

I'm trying to write a macro that will hide a row if the cells in column "g"
through to "r" are blank.

Can anyone help?

Thanks
 
Mat,

This should do what you want.

Sub stance()
Dim MyRange
Dim copyrange As Range
LastRow = Cells.SpecialCells(xlLastCell).Row
Set MyRange = Range("G1:G" & LastRow)
For Each c In MyRange
If WorksheetFunction.CountA(c.Resize(, 12)) = 0 Then
If copyrange Is Nothing Then
Set copyrange = c
Else
Set copyrange = Union(copyrange, c)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.EntireRow.Hidden = True
End If
End Sub


Mike
 

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

Back
Top