Write a macro that will open files with inputbox to search header for date. When it finds date, it will copy the range lines 101: 119 and paste them into ThisWorkbook at the Range of my choice. However, I ran into a problem right from the start in the headers search because it doesn't select the column I am looking for.
Rich (BB code):
Sub Makro10()
Dim data_wb As Workbook
Dim target_wb As Workbook
Dim file_name As Variant
Dim header_range(100) As Range
Dim When As String
Dim noreallywhen As String
'Open file
file_name = Application.GetOpenFilename(Title:="Choose a target Workbook")
If file_name <> False Then
'Setworkbook
Set target_wb = ThisWorkbook
'Set data file
Set data_wb = Application.Workbooks.Open(file_name)
'Input box
Do
inputbx = InputBox("Enter Date, FORMAT; YYY-MM-DD", , Format(VBA.Now, "YYYY-MM-DD"))
If inputbx = vbNullString Then Exit Sub
inputstr = Split(inputbx, "-")
On Error Resume Next
InputDate = DateSerial(inputstr(2), inputstr(0), inputstr(1))
On Error GoTo 0
DateIsValid = IsDate(InputDate)
If Not DateIsValid Then MsgBox "Please enter a valid date.", vbExclamation
Loop Until DateIsValid
If ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
data_wb.Sheets("Final").Rows("1:1").AutoFilter Field:=1, Criteria1:=CStr(InputDate)
End If
End If
End Sub