LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Auto delete rows within a specified range

You need to delete going backwords - otherwise, the when you delete, rows
shift and you can end up skipping rows. ex: If I delete row 19, row 20
becomes 19, so the next row I check is the old row 21 and row 20 doesn't get
checked.

Public Sub Delete_Rows()
Dim i as Long
for i = 28 to 19 step -1
if isempty(cells(i,"N")) then
rows(i).Delete
End if
Next
End Sub

--
Regards,
Tom Ogilvy


" wrote:

I'm new to VBA and trying to learn how to write code. My objective is
to automatically delete entire rows between row 19 and row 28 when the
value in column 11 in any of these rows is empty (null). Following is
the code I've written which, of course, does not work.

Public Sub Delete_Rows()

Dim GlobalRange As Range

Dim Range As Range

Set GlobalRange = Application.ActiveSheet.Range("N19:N28")

For Each Range In GlobalRange
If Range.Cells = "null" Then EntireRow.Delete

Next


End Sub


 
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
How do I get old rows to auto delete when new are added? Skippy Lou Excel Discussion (Misc queries) 1 May 7th 09 11:31 PM
If formula result is false, how do I auto-delete that rows? jbrenner51 Excel Worksheet Functions 1 November 16th 05 05:24 PM
Auto Filter Delete Rows by Criteria Doesn't Work Range To Complicated robertjtucker[_8_] Excel Programming 1 September 29th 05 05:47 PM
Need help to auto delete 4 of every 5 rows scratching my head Excel Programming 1 June 1st 05 11:54 PM
Auto Delete rows anurag.d[_9_] Excel Programming 5 July 2nd 04 12:11 PM


All times are GMT +1. The time now is 11:50 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"