Hello,
I have a macro that should, after typing in the date input, find this date in the open file data_wb. However, here
I have an error " Object dosen't support this property or method"
I would like open file data_wb and on sheet Final going to find my date. Where i did mistake ?
I have a macro that should, after typing in the date input, find this date in the open file data_wb. However, here
Rich (BB code):
For Each ws In data_wb.Sheets("Final")
I would like open file data_wb and on sheet Final going to find my date. Where i did mistake ?
Rich (BB code):
Dim vDate As Date
Dim Loc As Range
Dim data_wb As Workbook
'Open file
file_name = Application.GetOpenFilename(Title:="Choose a target Workbook")
If file_name <> False Then
'Set data file
Set data_wb = Application.Workbooks.Open(file_name)
Do
inputbx = InputBox("Enter Date, FORMAT; YYYY-MM-DD", , Format(VBA.Now, "YYYY-MM-DD"))
If inputbx = vbNullString Then Exit Sub
On Error Resume Next
vDate = DateValue(inputbx)
On Error GoTo 0
DateIsValid = IsDate(vDate)
If Not DateIsValid Then MsgBox "Please enter a valid date.", vbExclamation
Loop Until DateIsValid
For Each ws In data_wb.Sheets("Final")
ws.Activate
With ws
Set Loc = .Cells.Find(What:=vDate) 'It will find the firs cell that cointains the date as a date like (09/23/2021)
If Not Loc Is Nothing Then
Loc.Select
Exit For
End If