Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
print half of rows on left and other half on right | Excel Discussion (Misc queries) | |||
How to fix cell.entirerow.delete? | Excel Programming | |||
EntireRow.Delete | Excel Programming |