Hi all,
I've been trying to write a macro for my work that
1) searches for an erroneous cell "#N/A"
2) copies the data from this cell
3) looks for a string in another comulmn
4) if it finds that string, goes to the particular row
5) pastes the relevant data
6) delete the whole row with the "#N/A"
this is the code that I have come up with thus far:
My problem occurs on the line that starts with "c = Selection.Find..."
On my first run, it threw up a "Object Variable or With Block Variable not set" every time the string i was searching for in Column D was not found.
So I tried using some simple error handling using the On Error GoTo statement. Line 2 is the error handling process.
The issue is that the first time the Selection.Find command fails to find the string, the On Error command works fine, and the macro moves on to the next cell. But the second time it fails to find the string, it throws up the "Object Variable or With Block Variable not set" error, even though i already have an On Error statement.
What could be the problem?
As you probably can tell, im a beginner and the code is just brute forcing my way down a spreadsheet. Any suggestions to make this task more elegant would be extremely welcome.
The workbook is a bit too large to upload here, but if you need it for reference, PM me!
Bookmarks