title: Macro to find user input date range and delete everything outside range
body: <p>Wondering if someone could help me in developing a simple user interfacing macro. </p>
  
  <p>I have a set of data with the first Column (A) being dates. The date range can be an arbitrary range so could go from any start date to end date (most of the time its a 6/8 weeks). Lets say for arguments sake the date range goes from 31/12/2014 18:00 to 09/02/2015 18:00 (note date is UK format of dd/mm/yyyy). I would like the user to be asked for a start and end date range that they went - say 01/01/2015 to 31/01/2015. Once they have chosen the range the macro should delete everything BEFORE their selected date range (and shift cells up) and delete everything AFTER their selected date range. The date range is in increments of 10 minutes.</p>
  
  <p>I've written some code to start off:</p>
  
  <pre><code>Public Sub DateRngInput()
  
  Dim startDate As String
  Dim endDate As String
  Dim sRow As Long
  Dim eRow As Long
  Dim lastRow As Long
  
  lastRow = Cells(Rows.Count, 1).End(xlUp).Row
  startDate = Left(Worksheets("Template").Cells(1, 1), 10)
  endDate = Left(Worksheets("Template").Cells(lastRow, 1), 10)
  
  sDate = InputBox("Choose Start date (dd/mm/yyyy)" &amp; vbNewLine &amp; vbNewLine &amp; "Data range starts at " &amp; startDate)
  eDate = InputBox("Choose End date (dd/mm/yyyy)" &amp; vbNewLine &amp; vbNewLine &amp; "Data range ends at " &amp; endDate)
  
  'On Error Resume Next
  sRow = Worksheets("Template").Range("$A$1:$A" &amp; lastRow).Find(sDate, LookAt:=xlPart).Row
  eRow = Worksheets("Template").Range("$A$1:$A" &amp; lastRow).Find(eDate, SearchDirection:=xlPrevious, LookAt:=xlPart).Row
  
  MsgBox ("Your date range is from: " &amp; vbNewLine &amp; sDate &amp; " at Row " &amp; sRow &amp; vbNewLine &amp; "To " &amp; vbNewLine &amp; eDate &amp; " at Row " &amp; eRow)
  
  End Sub
  </code></pre>
  
  <p>The macro errors out at the following line with the Run-Time error '91':</p>
  
  <pre><code>sRow = Worksheets("Template").Range("$A$1:$A" &amp; lastRow).Find(sDate, LookAt:=xlPart).Row
  </code></pre>
  
  <p>Any help would be much appreciated!</p>
  
  <p>Thanks.</p>