Delete hidden cells

D

Dave Peterson

Maybe...

Option Explicit
Sub testme()
dim delRng as range
dim myCell as range
dim myRng as range

with worksheets("sheet9999")
set myrng = .range("a1:a99")
end with

for each mycell in myrng.columns(1).cells
if mycell.entirerow.hidden = true then
if delrng is nothing then
set delrng = mycell
else
set delrng = union(mycell, delrng)
end if
end if
next mycell

if delrng is nothing then
'nothing to do
else
delrng.entirerow.delete
end if

end sub

You'll want to change the worksheet name and the range address.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
B

brownti

thanks, that worked perfect!!


Dave said:
Maybe...

Option Explicit
Sub testme()
dim delRng as range
dim myCell as range
dim myRng as range

with worksheets("sheet9999")
set myrng = .range("a1:a99")
end with

for each mycell in myrng.columns(1).cells
if mycell.entirerow.hidden = true then
if delrng is nothing then
set delrng = mycell
else
set delrng = union(mycell, delrng)
end if
end if
next mycell

if delrng is nothing then
'nothing to do
else
delrng.entirerow.delete
end if

end sub

You'll want to change the worksheet name and the range address.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top