![]() |
Row deleting script problem
Hello Guys!
I have made a script for deleting rows where column A value is greater than 1280. It works fine but it will loop endlessly. What can I do about it? If I delete the "RowNumber = RowNumber - 1" then it does'nt work properly. TotalRows = Application.CountA(ActiveSheet.Range("A:A")) Cells(1, 1).Select For RowNumber = 1 To TotalRows If Cells(RowNumber, 1).Value 1280 Then Cells(RowNumber, 1).Select Selection.EntireRow.Delete RowNumber = RowNumber - 1 End If Next Please help me, Little Jessica ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Row deleting script problem
Jessica, try this
Public Sub DeleteHighRows() Dim lngLastRow As Long Dim lngTemp As Long lngLastRow = ActiveSheet.Range("A65500").End(xlUp).Row Application.ScreenUpdating = False For lngTemp = lngLastRow To 1 Step -1 If ActiveSheet.Cells(lngTemp, 1).Value 1280 Then ActiveSheet.Rows(lngTemp).Delete Next lngTemp Application.ScreenUpdating = True End Sub Regards Rog -----Original Message----- Hello Guys! I have made a script for deleting rows where column A value is greater than 1280. It works fine but it will loop endlessly. What can I do about it? If I delete the "RowNumber = RowNumber - 1" then it does'nt work properly. TotalRows = Application.CountA(ActiveSheet.Range("A:A")) Cells(1, 1).Select For RowNumber = 1 To TotalRows If Cells(RowNumber, 1).Value 1280 Then Cells(RowNumber, 1).Select Selection.EntireRow.Delete RowNumber = RowNumber - 1 End If Next Please help me, Little Jessica ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ . |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com