View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Delete unused rows / clear unused rows

Try...


Private Sub CommandButton2_Click()
Dim n&
With Application
.ScreenUpdating = False
.EnableEvents = False '//optional
End With

With Range("g5:g14")
For n = 10 To 1 Step -1
If .Cells(n) = "" Then .Rows(n).Delete
Next 'n
End With

With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub

...so your loop only acts on the target range!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion