title: Excel VBA, refresh data on opening if not refreshed today already
body: <p>I have an excel spreadsheet that uses pivot tables.</p>
  
  <p>Currently I have a hyperlink to refresh the data which is new each day.</p>
  
  <p>I would like to develop a method of refreshing the data on opening the Excel file, but not it it has already been updated today.</p>
  
  <p>Is this possible using VBA?</p>
  
  <p>My current code is...</p>
  
  <pre><code>Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
          If Target.Range.Address = "$A$1" Then
  
              MsgBox "Your data will now be updated.  This may take a moment..."
              ActiveWorkbook.RefreshAll
              Sheet1.Range("A2").Value = DateTime.Now
  
              Exit Sub
          End If
  
      End Sub
  </code></pre>
  
  <p>Thanks in advance.</p>