So here I have the nth question about the find method. I have read many questions about it and the problems it carries, but still couldnt find a solution to my problem.
I simply want to return the number of row and number of column for a particular value (a date). However, the code runs always the same 91 error (object variable not set) because the find method does not find anything.
I have tried to define the variable as range and change the code by setting the variable (i.e. set daterow = etc.). But the problem persists.
Sub actual_cash_flow()
Dim cfdate As Long
Dim today As Long
Dim daterow As Long
Dim datecolumn As Long
today = Date
cfdate = WorksheetFunction.EoMonth(today, -1)
daterow = Sheet2.Cells.Find(What:=cfdate, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, searchformat:=False).Row
datecolumn = Sheet2.Cells.Find(What:=cfdate).Column
End Sub
I would like to have number of row and number of column in order to identify the cell and then perform some actions.
EDIT:
By editing the code as suggested by @mikku and by debugging the range where there is the value and the variable defined in the code I get the same value, however, I still get nothing as output. So I really dont know where the error is. See the image.