VB Excel 2010 - Loop until can't find
Solved/Closed
Related:
- Vba loop until error
- Network error occurred - Guide
- Vba case like - Guide
- Cmos checksum error - Guide
- Game loop - Download - Android emulators
- Fruity loop download - Download - Musical production
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Jun 7, 2011 at 02:31 AM
Jun 7, 2011 at 02:31 AM
The code says
Do While lNum > 10
So when does lNum ever becomes less than or equal to 10 to terminate the loop
Since you have not given all info, this I am thinking is the most logical solution
Do While lNum > 10
So when does lNum ever becomes less than or equal to 10 to terminate the loop
Since you have not given all info, this I am thinking is the most logical solution
Do While True Set Cell = Columns(2).Find(What:="CE - Parish Currently", _ After:=Cells(1, 2), _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) If Cell Is Nothing Then Exit Do Cell.EntireRow.Delete Loop
Jun 7, 2011 at 05:32 PM
This works great except that I forgot to mention that we need it to delete more than just the row with the words in it. It needs to delete the row with the words and the 8 rows directly below it as well - so 9 rows in total. Been trying to play with what you've given me but can't seem to figure out a way to get it to do that second part as well....
Jun 7, 2011 at 05:48 PM
Cell.EntireRow.Delete
to
Range(Cell, Cells(Cell.Row + 8, Cell.Column)).EntireRow.Delete
Jun 7, 2011 at 06:24 PM
Jun 8, 2011 at 07:29 PM
Just trying to use this loop in another macro but it doesn't seem to like the command I've given it. It's almost exactly the same except the search words and the last command.
Rather than deleting a specific number of rows beneath the specified search words, because the amount of info varies we want it to select the entire section of info underneath (we used the shortcut Shift - End - Down arrow to make the selection). This is what I've tried but hasn't worked.
Do While True
Set cell = Columns(2).Find(What:="other dues", _
After:=Cells(1, 2), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If cell Is Nothing Then Exit Do
Range(Selection, Selection.End(xlDown)).EntireRow.Delete
Are you able to shed some light?
Jun 9, 2011 at 03:49 AM
Range(Selection, Selection.End(xlDown)).EntireRow.Delete
try
Range(cell , cell.End(xlDown)).EntireRow.Delete