Date Stamp for Table Refresh

jbvinny

Active Member
Joined
Nov 21, 2007
Messages
274
I have a database connection that gets refreshed manually by the end user. What I need is to place the date stamp of the last refresh date in a cell (say J1) so that anytime the table is refreshed the date is refreshed. Simply using =now() does not work because that cell is updated each time the workbook is opened or refreshed and I only want the value to update when the table is refreshed. Does anyone have any ideas? Maybe a UDF or a Pivot Table Refresh Event?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You can certainly use a worksheet's pivottableupdate event to enter the current date/time in a cell:
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
   Me.Range("J1").Value = Now
End Sub
for example.
 
Upvote 0
But its a data table not a pivot table. I have been able to find code that would work for a pivot table but nothing for data. Sorry if I am being dense.
 
Upvote 0
Well, you're the one who mentioned pivot tables so I assumed there was a PT involved...

If not, you can use a WithEvents Querytable variable, or use a UDF that looks at the refreshdate of the ODBCConnection (or OLEDBCOnnection) and make it volatile.
 
Upvote 0
Sorry! I just looked at my original post and it looks like I did mention PT. Can you point me in the right direction as far as the code would go for either of those?
 
Upvote 0
I was actually able to solve this by just creating a macro and button to refresh the table and as part of that code it also inserts the date. But obviously that only works if the button is used to refresh the connection.
 
Upvote 0
For example in the code module of the worksheet containing the query table:
Code:
Private WithEvents qt As QueryTable

Private Sub qt_AfterRefresh(ByVal Success As Boolean)
   Me.Range("J1").Value = Now()
End Sub

Private Sub Worksheet_Activate()
   Set qt = Me.ListObjects(1).QueryTable
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,345
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top