![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: North Wales Coast, UK
Posts: 95
|
Evening All,
I am looking to Find a Value in a list dosome deleting of relevant data in the same row and move onto the next occurrence of the same Value in the list. I seem to sorted that out but I have encountered an error code after the last Value: Runtime Error'91' Object Variable or With block variable not set The code line on Debug is: Cells.FindNext(After:=ActiveCell).Activate I would ideally like to operate an IF statement to 'break out' if the FindNext 'fails' but it seems to be eluding me at the moment. Any help appreciated. Cheers S |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
The help file in excel has an example of how to jump out of a find next :
Code:
With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
__________________
<MARQUEE>...........Never be afraid to try something new. Remember, amateurs built the ark, professionals built the Titanic...............The easiest thing to find is fault, don't be easy !.. --Anonymous--...</marquee> |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|