LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete unused rows Forgone Excel Programming 2 September 26th 08 03:56 AM
macro to delete hidden or unused rows Cam Excel Programming 1 February 28th 08 08:35 PM
Hiding Unused Rows [email protected] Excel Programming 1 January 19th 07 10:40 PM
Delete Unused (4000) Rows VexedFist[_2_] Excel Programming 3 September 22nd 06 09:54 PM
VB Code to Delete Unused Rows Ken[_18_] Excel Programming 2 October 1st 04 04:35 AM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"