title: picking out worksheet with maximum date
body: <p>I am trying to select a sheet from the workbook that has the newest date. The date is in the same space for each sheet, otherwise it is blank or text, and therefore should never evaluate as greater than an integer or date formatted value i think. Once i have found that sheet i want to take specific data and use it. My problem is selecting the correct sheet. Here is the code:</p>
  
  <pre><code>Dim wksht As Worksheet
  Dim maxsheet As Worksheet
  Dim currentdate as Integer
  Dim maxdate as Integer
  
  'go through each worksheet. compare the value of current date extracted from each sheet
  'to maxdate. If currentdate &gt; maxdate maxdate = currentdate.
  'remember the worksheet for maxdate as maxsheet.
  
  maxdate = 0
  For Each wksht In ActiveWorkbook.Worksheets
      With wksht
          currentdate = wksht.Range("B1").Value
          If currentdate &gt; maxdate Then
              maxsheet = wksht
              maxdate = currentdate
          End If
      End With
  Next wksht
  </code></pre>
  
  <p>What is going on? The error i get is "'91': Object variable or with block variable not set." I don't really understand the help section or how i can fix it.</p>
  
  <p>Looking at the code again i foresee another problem, working with the sheet once i have the sheet stored. Can i just use maxsheet.select for that?</p>