![]() |
Creating a loop
I have the macro below that works fine - but for the life of me I cannot get
it to loop without giving me an error. I need it look through all the text that could exist in column "A" could be 20 rows could be 10,000. If anyone could help I would appreciate it. Thanks in advance, Sub Delete() Dim Range1 As Range Dim Range2 As Range Set Range1 = Cells.Find(what:="*** NO OPE") 'you can fill in the conditions Set Range2 = Cells.Find(what:="*** NO SAL") Range(Range1.EntireRow, Range2.EntireRow).Delete 'Then to move to the cell above resultsSet Range2 = Range2.Offset(0, 0) 'Clears cells End Sub -- Jake |
Creating a loop
Sub Delete()
Dim Range1 As Range Dim Range2 As Range Do Set Range1 = Nothing Set Range1 = Columns(1).Find(what:="*** NO OPE") 'you can fill in the conditions If Not Range1 Is Nothing Then Set Range2 = Nothing Set Range2 = Columns(1).Find(what:="*** NO SAL") If Not Range2 Is Nothing Then Range(Range1.EntireRow, Range2.EntireRow).Delete 'Then to move to the cell above resultsSet Range2 = Range2.Offset(0, 0) 'Clears cells End If End If Loop Until Range1 Is Nothing Or Range2 Is Nothing End Sub -- __________________________________ HTH Bob "JakeShipley2008" wrote in message ... I have the macro below that works fine - but for the life of me I cannot get it to loop without giving me an error. I need it look through all the text that could exist in column "A" could be 20 rows could be 10,000. If anyone could help I would appreciate it. Thanks in advance, Sub Delete() Dim Range1 As Range Dim Range2 As Range Set Range1 = Cells.Find(what:="*** NO OPE") 'you can fill in the conditions Set Range2 = Cells.Find(what:="*** NO SAL") Range(Range1.EntireRow, Range2.EntireRow).Delete 'Then to move to the cell above resultsSet Range2 = Range2.Offset(0, 0) 'Clears cells End Sub -- Jake |
All times are GMT +1. The time now is 01:25 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com