VBA Search for specific column header(date), by inputbox and select rows

Status
Not open for further replies.

Palucci

Banned user
Joined
Sep 15, 2021
Messages
138
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Status
Not open for further replies.

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top