Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default EntireRow.Delete only removing half of the rows

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default EntireRow.Delete only removing half of the rows

hi KelliInCali

You not start on the bottom

See Examples to delete on my site
http://www.rondebruin.nl/delete.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"KelliInCali" wrote in message ...
Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default EntireRow.Delete only removing half of the rows

As Ron pointed out if you want to delete you need to move from the bottom up,
or you can just collect all of the cells that you find into one big range
object and delete them all in one big delete. Depending on how many rows you
have to delete this can be quite a bit faster...

Sub test()
Dim rngCurrentCell As Range
Dim rngFoundAll As Range

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
If rngFoundAll Is Nothing Then
Set rngFoundAll = rngCurrentCell
Else
Set rngFoundAll = Union(rngCurrentCell, rngFoundAll)
End If

End If
Next
If Not rngFoundAll Is Nothing Then rngFoundAll.EntireRow.Delete

End Sub
--
HTH...

Jim Thomlinson


"KelliInCali" wrote:

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default EntireRow.Delete only removing half of the rows

Hi KelliInCali and Jim

I like to add this to Jim's reply:

You can find a Union example on my site also
See that I do a test for a error in the loop.
Jim's code blow if you have a error in column H



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
As Ron pointed out if you want to delete you need to move from the bottom up,
or you can just collect all of the cells that you find into one big range
object and delete them all in one big delete. Depending on how many rows you
have to delete this can be quite a bit faster...

Sub test()
Dim rngCurrentCell As Range
Dim rngFoundAll As Range

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
If rngFoundAll Is Nothing Then
Set rngFoundAll = rngCurrentCell
Else
Set rngFoundAll = Union(rngCurrentCell, rngFoundAll)
End If

End If
Next
If Not rngFoundAll Is Nothing Then rngFoundAll.EntireRow.Delete

End Sub
--
HTH...

Jim Thomlinson


"KelliInCali" wrote:

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default EntireRow.Delete only removing half of the rows

Thanks Ron... Somehow today is not my day... My code will crash if no cells
are found to delete... Thanks for catching that... Speaking of blow, my
transmission blew today. Regretably my day has not improved since then. I
think I might just go back to bed now before I do any more damage...
--
HTH...

Jim Thomlinson


"Ron de Bruin" wrote:

Hi KelliInCali and Jim

I like to add this to Jim's reply:

You can find a Union example on my site also
See that I do a test for a error in the loop.
Jim's code blow if you have a error in column H



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
As Ron pointed out if you want to delete you need to move from the bottom up,
or you can just collect all of the cells that you find into one big range
object and delete them all in one big delete. Depending on how many rows you
have to delete this can be quite a bit faster...

Sub test()
Dim rngCurrentCell As Range
Dim rngFoundAll As Range

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
If rngFoundAll Is Nothing Then
Set rngFoundAll = rngCurrentCell
Else
Set rngFoundAll = Union(rngCurrentCell, rngFoundAll)
End If

End If
Next
If Not rngFoundAll Is Nothing Then rngFoundAll.EntireRow.Delete

End Sub
--
HTH...

Jim Thomlinson


"KelliInCali" wrote:

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default EntireRow.Delete only removing half of the rows

Hi Jim

transmission blew today

That is not so funny

think I might just go back to bed now before I do any more damage...

LOL

Have a good night

For me also (23:33 here)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
Thanks Ron... Somehow today is not my day... My code will crash if no cells
are found to delete... Thanks for catching that... Speaking of blow, my
transmission blew today. Regretably my day has not improved since then. I
think I might just go back to bed now before I do any more damage...
--
HTH...

Jim Thomlinson


"Ron de Bruin" wrote:

Hi KelliInCali and Jim

I like to add this to Jim's reply:

You can find a Union example on my site also
See that I do a test for a error in the loop.
Jim's code blow if you have a error in column H



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
As Ron pointed out if you want to delete you need to move from the bottom up,
or you can just collect all of the cells that you find into one big range
object and delete them all in one big delete. Depending on how many rows you
have to delete this can be quite a bit faster...

Sub test()
Dim rngCurrentCell As Range
Dim rngFoundAll As Range

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
If rngFoundAll Is Nothing Then
Set rngFoundAll = rngCurrentCell
Else
Set rngFoundAll = Union(rngCurrentCell, rngFoundAll)
End If

End If
Next
If Not rngFoundAll Is Nothing Then rngFoundAll.EntireRow.Delete

End Sub
--
HTH...

Jim Thomlinson


"KelliInCali" wrote:

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default EntireRow.Delete only removing half of the rows

I was wondering. I don't normally see you here at this time but Tom is there
24/7 so nothing surprises me anymore... By the way where is Tom??? It is
kinda lonely here without him...
--
HTH...

Jim Thomlinson


"Ron de Bruin" wrote:

Hi Jim

transmission blew today

That is not so funny

think I might just go back to bed now before I do any more damage...

LOL

Have a good night

For me also (23:33 here)



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
Thanks Ron... Somehow today is not my day... My code will crash if no cells
are found to delete... Thanks for catching that... Speaking of blow, my
transmission blew today. Regretably my day has not improved since then. I
think I might just go back to bed now before I do any more damage...
--
HTH...

Jim Thomlinson


"Ron de Bruin" wrote:

Hi KelliInCali and Jim

I like to add this to Jim's reply:

You can find a Union example on my site also
See that I do a test for a error in the loop.
Jim's code blow if you have a error in column H



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jim Thomlinson" wrote in message
...
As Ron pointed out if you want to delete you need to move from the bottom up,
or you can just collect all of the cells that you find into one big range
object and delete them all in one big delete. Depending on how many rows you
have to delete this can be quite a bit faster...

Sub test()
Dim rngCurrentCell As Range
Dim rngFoundAll As Range

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
If rngFoundAll Is Nothing Then
Set rngFoundAll = rngCurrentCell
Else
Set rngFoundAll = Union(rngCurrentCell, rngFoundAll)
End If

End If
Next
If Not rngFoundAll Is Nothing Then rngFoundAll.EntireRow.Delete

End Sub
--
HTH...

Jim Thomlinson


"KelliInCali" wrote:

Hello.. The following loop is only deleting half of the rows it should be
targeting. It deletes from the bottom of the selection up, but only half of
the records. If I back up and step into it again, it deletes half again of
the remaining.

Can anyone tell me what I'm missing? Tks, Kelli

Set tbl = ActiveCell.CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count - 1, tbl.Columns.Count).Select

For Each rngCurrentCell In Worksheets("Floor").Range("H:H").Cells
If rngCurrentCell.Value < 0.01 Then
rngCurrentCell.EntireRow.Delete
End If
Next







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
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 4 July 20th 08 11:07 AM
Need Help with ActiveCell.EntireRow.Delete Ayo Excel Discussion (Misc queries) 8 July 19th 08 04:45 PM
print half of rows on left and other half on right Steve B. Excel Discussion (Misc queries) 2 November 16th 07 11:20 AM
How to fix cell.entirerow.delete? guy Excel Programming 1 March 10th 05 02:31 AM
EntireRow.Delete Steph[_3_] Excel Programming 14 January 21st 05 10:31 PM


All times are GMT +1. The time now is 01:00 AM.

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"