I have a part of macro which, after typing in the inputbox, finds the name of the column (date), after finding it, it needs to copy a given fragment of rows from this column, always after finding a given cell, it will be the same range. But i dont knot excatly how please take a look as below code
''' Put date input box ''' Sub Makro10() Dim vDate As Date Dim wbMe As Workbook Dim data_wb As Workbook Dim ws As Worksheet Dim inputbx As String 'Set workbook' Set wbMe = ActiveWorkbook wbMe.Sheets("input_forecast").Rows("1:1").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.NumberFormat = "YYYY-MM-DD" Set wbMe = ThisWorkbook 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) 'paste copy like value and change to date format' data_wb.Sheets("Final").Rows("1:1").Select Selection.Copy Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.NumberFormat = "YYYY-MM-DD" 'set our ws' ''' Put date input box ''' Do inputbx = InputBox("Date, FORMAT; YYYY-MM-DD") If inputbx = vbNullString Then Exit Sub On Error Resume Next vDate = CDate(inputbx) On Error GoTo 0 DateIsValid = IsDate(vDate) If Not DateIsValid Then MsgBox "Please enter a valid date.", vbExclamation Loop Until DateIsValid 'COPY loop" Dim loc As Range, lc As Long With data_wb.Sheets("Final") Set loc = .Cells.Find(what:=Format(inputbx, "YYYY-MM-DD")) If Not loc Is Nothing Then lc = .Cells(loc.Row, Columns.Count).End(xlToLeft).Column .Range(.Cells(109, loc.Column), .Cells(123, lc)).Copy End If End With End If End Sub 