title: Copying all data from a table in one tab into another tab in the same workbook based on 2 input boxes which will define a date range
body: <p>i have tried many sites and am really struggling as i cant seem to understand the VBA code</p>
  <p>tab1 = data from C8:Rx? ... the data will continously grow so table will get bigger all the time</p>
  <p>Column C in tab1 contains dates 21/05/2021</p>
  <p>I want to be able to have 2 prompt boxes where i enter a date from and date to 21/05/2021 - 22/05/2021</p>
  <p>when i action the macro it will take only the data from the table in tab1 in between these dates</p>
  <p>and paste them in tab2 at cell ref c8 (the start of the table)</p>
  <pre><code>Option Explicit
  
  'This subroutine prompts the user to select dates
  Public Sub PromptUserForInputDates()
      
      Dim strStart As String, strEnd As String, strPromptMessage As String
      
      'Prompt the user to input the start date
      strStart = InputBox(&quot;Please enter the start date&quot;)
      
      'Validate the input string
      If Not IsDate(strStart) Then
          strPromptMessage = &quot;Oops! It looks like your entry is not a valid &quot; &amp; _
                             &quot;date. Please retry with a valid date...&quot;
          MsgBox strPromptMessage
          Exit Sub
      End If
      
      'Prompt the user to input the end date
      strEnd = InputBox(&quot;Please enter the end date&quot;)
      
      'Validate the input string
      If Not IsDate(strStart) Then
          strPromptMessage = &quot;Oops! It looks like your entry is not a valid &quot; &amp; _
                             &quot;date. Please retry with a valid date...&quot;
          MsgBox strPromptMessage
          Exit Sub
      End If
      
      'Call the next subroutine, which will do produce the output workbook
      Call CreateSubsetWorkbook(strStart, strEnd)
      
  End Sub
  </code></pre>
  <pre><code>'This subroutine creates the new workbook based on input from the prompts
  Public Sub CreateSubsetWorkbook(StartDate As String, EndDate As String)
      
      Dim wbkOutput As Workbook
      Dim wksOutput As Worksheet, wks As Worksheet
      Dim lngLastRow As Long, lngLastCol As Long, lngDateCol As Long
      Dim rngFull As Range, rngResult As Range, rngTarget As Range
      
      'Set references up-front
      lngDateCol = 3 '&lt;~ we know dates are in column C
      Set wbkOutput = Workbooks.Add
      
      'Loop through each worksheet
      For Each wks In ThisWorkbook.Worksheets
          With wks
          
              'Create a new worksheet in the output workbook
              Set wksOutput = wbkOutput.Sheets.Add
              wksOutput.Name = wks.Name
              
              'Create a destination range on the new worksheet that we
              'will copy our filtered data to
              Set rngTarget = wksOutput.Cells(1, 1)
          
              'Identify the data range on this sheet for the autofilter step
              'by finding the last row and the last column
              lngLastRow = .Cells.Find(What:=&quot;*&quot;, LookIn:=xlFormulas, _
                                   SearchOrder:=xlByRows, _
                                   SearchDirection:=xlPrevious).Row
              lngLastCol = .Cells.Find(What:=&quot;*&quot;, LookIn:=xlFormulas, _
                                   SearchOrder:=xlByColumns, _
                                   SearchDirection:=xlPrevious).Column
              Set rngFull = .Range(.Cells(1, 1), .Cells(lngLastRow, lngLastCol))
              
              'Apply a filter to the full range to get only rows that
              'are in between the input dates
              With rngFull
                  .AutoFilter Field:=lngDateCol, _
                              Criteria1:=&quot;&gt;=&quot; &amp; StartDate, _
                              Criteria2:=&quot;&lt;=&quot; &amp; EndDate
                  
                  'Copy only the visible cells and paste to the
                  'new worksheet in our output workbook
                  Set rngResult = rngFull.SpecialCells(xlCellTypeVisible)
                  rngResult.copy Destination:=rngTarget
              End With
              
              'Clear the autofilter safely
              .AutoFilterMode = False
              If .FilterMode = True Then
                  .ShowAllData
              End If
          End With
      Next wks
      
      'Let the user know our macro has finished!
      MsgBox &quot;Data transferred!&quot;
  
  End Sub
  </code></pre>
  <p><img src="https://i.stack.imgur.com/8grFu.png" alt="enter image description here" /></p>