I have the following snippet VBA:
DatetoRun = InputBox("How far back do you want to run the MI for?", "Date backing", Format(Now(), "dd/mm/yyyy"))
'Date validation for DatetoRun
If IsDate(DatetoRun) Then
DatetoRun = Format(CDate(DatetoRun), "dd/mm/yyyy")
dateStart = DatetoRun
Else
MsgBox "Please enter a DATE in the correct format dd/mm/yyyy"
End If
Set found = Range("A:A").Find(what:=DatetoRun, LookIn:=xlValues, lookat:=xlWhole)
iclearrow = found.Row
When executing it I keep getting the
Object Variable or With Block variable not set
which confuses me as I am setting it:
Set found = Range("A:A").Find(what:=DatetoRun, LookIn:=xlValues, lookat:=xlWhole)
The error happens on the last row:
iclearrow = found.Row
Not sure how or why this is happening. also sometime it will randomly work once, but then error out after. Nothing is consistent!