Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default deleting rows in a non-continous range

You have to start from the bottom of the range and move to the top

dim i as long
With Workbooks("test").Worksheets("MHE").range("CHECKRA NGE")
For i = .Rows.Count To 1 Step -1
If .Cells(i).Value = 0 Then .Rows(i).EntireRow.Delete
Next
end with

"Tim McPhillips" wrote in message
...
I need help with the following problem. A worksheet with
a non-continous range has data that occassionally has zero
populated. I need code that will cycle through the entire
range, identify if any cells are zero, and delete those
rows. My code isn't working. This is what I came up with:


("CHECKRANGE")
Set c = Workbooks("test").Worksheets("MHE").range
_
.Cells(1)

For xy = 1 To Workbooks("test").Worksheets("MHE") _
.range("CHECKRANGE").Count

If c.Value = 0 Then
Set deleteaddress = range(c.Address)
Set c = c.Next
deleteaddress.Select
selection.EntireRow.Delete
Else
Set c = c.Next
End If

Next xy

End With


Any help would be appreciated!

Thanks,

Tim



Reply
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
Deleting a range of rows based on a variable; syntax error Babymech Excel Discussion (Misc queries) 3 January 16th 09 06:19 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
MACRO HELP - deleting rows containing a range of blank cells DavidHawes Excel Discussion (Misc queries) 9 February 26th 07 03:40 PM
Deleting rows in a range using Autofilter Connie Excel Discussion (Misc queries) 3 October 17th 06 01:47 PM
Deleting Range name's listed in the range address box. Satnam Patel Excel Discussion (Misc queries) 4 May 5th 05 01:42 PM


All times are GMT +1. The time now is 12:26 AM.

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

About Us

"It's about Microsoft Excel"