VB Excel 2010 - Loop until can't find
Solved/Closed
Related:
- Vb net excel 2010
- Microsoft picture manager 2010 - Download - Image viewing and management
- Ms office 2010 free download - Download - Office suites
- Excel mod apk for pc - Download - Spreadsheets
- Vb net find last row in excel sheet - Guide
- Pdf and xps add in 2010 - Download - Other
1 response
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
7 Jun 2011 à 02:31
7 Jun 2011 à 02:31
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
7 Jun 2011 à 17:32
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....
7 Jun 2011 à 17:48
Cell.EntireRow.Delete
to
Range(Cell, Cells(Cell.Row + 8, Cell.Column)).EntireRow.Delete
7 Jun 2011 à 18:24
8 Jun 2011 à 19:29
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?
9 Jun 2011 à 03:49
Range(Selection, Selection.End(xlDown)).EntireRow.Delete
try
Range(cell , cell.End(xlDown)).EntireRow.Delete