ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do you hide multiple row macro (https://www.excelbanter.com/excel-discussion-misc-queries/246211-how-do-you-hide-multiple-row-macro.html)

Matt[_5_]

How do you hide multiple row macro
 
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

Mike H

How do you hide multiple row macro
 
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

"Matt" wrote:

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



All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com