I have a bit of VBA that I've used on multiple occasions. I look for a row of data in a table, and if it's not there, I add it. If it is, I overwrite the data. Here's how I do it:
Code
DataFound = 0
On Error Resume Next
DataFound = Columns(1).Find(What:=DateTime, After:=Cells(1, 1), LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row
On Error GoTo 0
'If data is not in the table, add the data
If DataFound = 0 Then
InputRow = Sheet7.Range("a" & Rows.Count).End(xlUp).Row
Else
'If data is in the table, overwrite the data
InputRow = DataFound - 1
End If
Display More
I've used similar code before with great success, but for some reason I'm now getting "Run-time error '91': Object variable or With block variable not set" and it's the DataFound = Columns(1).Find... line that is causing the error. I expect it to error... the data isn't there, right? But that's why I have the line of code "On Error Resume Next" there. Very confused as to why that isn't happening.
Any ideas?