PC Review


Reply
Thread Tools Rate Thread

How to auto-enter a date for when your sheet was last updated

 
 
Colin Hayes
Guest
Posts: n/a
 
      20th Nov 2010

Hi

I update my worksheet with data from the Internet by clicking the
'Refresh All' icon.

What I need to do is to have a cell show the date (dd/mm/yyyy) when the
sheet was last updated , before I go to get the new data.

Can someone help with this?


Grateful for any advice

Best Wishes
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      20th Nov 2010
Right-click on the sheet tab and "View Code" to open module.

Copy/paste this event code into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A1")
'edit to suit. chosen cell must be within refreshed data range
If .Value <> "" Then
Me.Range("D1").Value = Format(Now, "dd-mm-yy hh:mm:ss")
'edit "D1" to suit where you want the date/time entered
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Sat, 20 Nov 2010 00:10:43 +0000, Colin Hayes <(E-Mail Removed)>
wrote:

>
>Hi
>
>I update my worksheet with data from the Internet by clicking the
>'Refresh All' icon.
>
>What I need to do is to have a cell show the date (dd/mm/yyyy) when the
>sheet was last updated , before I go to get the new data.
>
>Can someone help with this?
>
>
>Grateful for any advice
>
>Best Wishes

 
Reply With Quote
 
Colin Hayes
Guest
Posts: n/a
 
      20th Nov 2010
In article <(E-Mail Removed)>, Gord Dibben
<(E-Mail Removed)> writes
>Right-click on the sheet tab and "View Code" to open module.
>
>Copy/paste this event code into the sheet module.
>
>Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> With Me.Range("A1")
> 'edit to suit. chosen cell must be within refreshed data range
> If .Value <> "" Then
> Me.Range("D1").Value = Format(Now, "dd-mm-yy hh:mm:ss")
> 'edit "D1" to suit where you want the date/time entered
> End If
> End With
>stoppit:
> Application.EnableEvents = True
>End Sub
>


Hi Gord

OK thanks for getting back.

No joy , I'm afraid.

I assume you need me to change A1 in the code to one the cells in my
sheet which is being refreshed , and I wanted the date to be entered in
B16.

I tried modifying the code accordingly , but I kept getting errors. My
fault I'm sure. When I refreshed , I lost all figures in the sheet to
question marks and value errors. I'll keep trying.


Best Wishes.



 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      20th Nov 2010
The code will not produce the question marks and value errors when you refresh
data.

What happens when you refresh data on your original sheet without the code?

Simply editing "A1" to another cell should not produce any errors within the
code.

Make sure "B16" is out of refresh range.

Did you for sure add the code to the sheet module?

What type of errors does the code throw up?

Can you post your attempt at amended code?


Gord

On Sat, 20 Nov 2010 03:31:17 +0000, Colin Hayes <(E-Mail Removed)>
wrote:

>In article <(E-Mail Removed)>, Gord Dibben
><(E-Mail Removed)> writes
>>Right-click on the sheet tab and "View Code" to open module.
>>
>>Copy/paste this event code into the sheet module.
>>
>>Private Sub Worksheet_Change(ByVal Target As Range)
>> On Error GoTo stoppit
>> Application.EnableEvents = False
>> With Me.Range("A1")
>> 'edit to suit. chosen cell must be within refreshed data range
>> If .Value <> "" Then
>> Me.Range("D1").Value = Format(Now, "dd-mm-yy hh:mm:ss")
>> 'edit "D1" to suit where you want the date/time entered
>> End If
>> End With
>>stoppit:
>> Application.EnableEvents = True
>>End Sub
>>

>
>Hi Gord
>
>OK thanks for getting back.
>
>No joy , I'm afraid.
>
>I assume you need me to change A1 in the code to one the cells in my
>sheet which is being refreshed , and I wanted the date to be entered in
>B16.
>
>I tried modifying the code accordingly , but I kept getting errors. My
>fault I'm sure. When I refreshed , I lost all figures in the sheet to
>question marks and value errors. I'll keep trying.
>
>
>Best Wishes.
>
>

 
Reply With Quote
 
Colin Hayes
Guest
Posts: n/a
 
      20th Nov 2010
In article <(E-Mail Removed)>, Gord Dibben
<(E-Mail Removed)> writes
>The code will not produce the question marks and value errors when you refresh
>data.
>
>What happens when you refresh data on your original sheet without the code?
>
>Simply editing "A1" to another cell should not produce any errors within the code.
>
>Make sure "B16" is out of refresh range.
>
>Did you for sure add the code to the sheet module?
>
>What type of errors does the code throw up?
>
>Can you post your attempt at amended code?
>
>
>Gord



Hi Gord

Thanks for getting back.

I've since found that the question marks were caused by a server issue
at
the site I'm updating from , so that's not from the code.

When I refresh the data without the code , it updates the numbers it
fetches from the internet as it should.

I'm changing A1 in the code to D4 , which is one of the cells that will
be
updated on refresh.

B16 is a blank cell on the sheet where I want the date / to be placed.

I'm putting the code under the tab on the sheet I'm refreshing.

When I refresh with the code in place , the numbers do refresh as they
should , but nothing is showing in B16.

Here's the code I'm putting in :

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("D4")
'edit to suit. chosen cell must be within refreshed data range
If .Value <> "" Then
Me.Range("B16").Value = Format(Now, "dd-mm-yy hh:mm:ss")
'edit "D1" to suit where you want the date/time entered
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


For your interest , I've put the file itself here :

http://www.chayes.demon.co.uk/ShareSample.xls



Best Wishes


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      21st Nov 2010
>When I refresh with the code in place , the numbers do refresh as they
>should , but nothing is showing in B16.


ShareSheet is protected so changes to B16 cannot be made.

Because I error-trapped the code, you don't see an error message informing you
of that fact.

Also, the data refresh is actually done on LookUpData sheet and ShareSheet D4 is
only a reference to D4 on that sheet,

We could change the event type to Calculate but that would also update B16 when
VirtualLookUpData is refreshed..............not desirable, I would say.

Delete the code you have in ShareSheet

The following amended code goes into module of LookUpData sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Me.Range("D4").Value <> "" Then
With Sheets("ShareSheet")
.Unprotect Password:="justme"
.Range("B16").Value = Format(Now, "dd-mm-yy hh:mm:ss")
stoppit:
Application.EnableEvents = True
.Protect Password:="justme"
End With
End If
End Sub

The code unprotects ShareSheet so the date/time can be added to B16

I used a cracker to unprotect ShareSheet for testing the code..

Works fine for me when I refresh data on LookUpData sheet.

Edit password "justme" to your actual password.


Gord

On Sat, 20 Nov 2010 22:47:03 +0000, Colin Hayes <(E-Mail Removed)>
wrote:

>In article <(E-Mail Removed)>, Gord Dibben
><(E-Mail Removed)> writes
>>The code will not produce the question marks and value errors when you refresh
>>data.
>>
>>What happens when you refresh data on your original sheet without the code?
>>
>>Simply editing "A1" to another cell should not produce any errors within the code.
>>
>>Make sure "B16" is out of refresh range.
>>
>>Did you for sure add the code to the sheet module?
>>
>>What type of errors does the code throw up?
>>
>>Can you post your attempt at amended code?
>>
>>
>>Gord

>
>
>Hi Gord
>
>Thanks for getting back.
>
>I've since found that the question marks were caused by a server issue
>at
>the site I'm updating from , so that's not from the code.
>
>When I refresh the data without the code , it updates the numbers it
>fetches from the internet as it should.
>
>I'm changing A1 in the code to D4 , which is one of the cells that will
>be
>updated on refresh.
>
>B16 is a blank cell on the sheet where I want the date / to be placed.
>
>I'm putting the code under the tab on the sheet I'm refreshing.
>
>When I refresh with the code in place , the numbers do refresh as they
>should , but nothing is showing in B16.
>
>Here's the code I'm putting in :
>
>Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> With Me.Range("D4")
> 'edit to suit. chosen cell must be within refreshed data range
> If .Value <> "" Then
> Me.Range("B16").Value = Format(Now, "dd-mm-yy hh:mm:ss")
> 'edit "D1" to suit where you want the date/time entered
> End If
> End With
>stoppit:
> Application.EnableEvents = True
>End Sub
>
>
>For your interest , I've put the file itself here :
>
>http://www.chayes.demon.co.uk/ShareSample.xls
>
>
>
>Best Wishes
>

 
Reply With Quote
 
Colin Hayes
Guest
Posts: n/a
 
      21st Nov 2010
In article <(E-Mail Removed)>, Gord Dibben
<(E-Mail Removed)> writes
>>When I refresh with the code in place , the numbers do refresh as they
>>should , but nothing is showing in B16.

>
>ShareSheet is protected so changes to B16 cannot be made.
>
>Because I error-trapped the code, you don't see an error message informing you of
>that fact.
>
>Also, the data refresh is actually done on LookUpData sheet and ShareSheet D4 is
>only a reference
>to D4 on that sheet,
>
>We could change the event type to Calculate but that would also update B16 when
>VirtualLookUpData is refreshed..............not desirable, I would say.
>
>Delete the code you have in ShareSheet
>
>The following amended code goes into module of LookUpData sheet.
>
>Private Sub Worksheet_Change(ByVal Target As Range)
>On Error GoTo stoppit
> Application.EnableEvents = False
> If Me.Range("D4").Value <> "" Then
> With Sheets("ShareSheet")
> .Unprotect Password:="justme"
> .Range("B16").Value = Format(Now, "dd-mm-yy hh:mm:ss")
>stoppit:
> Application.EnableEvents = True
> .Protect Password:="justme"
> End With
> End If
>End Sub
>
>The code unprotects ShareSheet so the date/time can be added to B16
>
>I used a cracker to unprotect ShareSheet for testing the code..
>
>Works fine for me when I refresh data on LookUpData sheet.
>
>Edit password "justme" to your actual password.
>
>
>Gord



Hi Gord

OK I ran it and it works perfectly. Exactly the solution to the problem.

Thanks very much indeed - I'm grateful to you for your time and
expertise.


Best Wishes
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      22nd Nov 2010
Happy to oblige


Gord

On Sun, 21 Nov 2010 20:30:13 +0000, Colin Hayes <(E-Mail Removed)>
wrote:

>Hi Gord
>
>OK I ran it and it works perfectly. Exactly the solution to the problem.
>
>Thanks very much indeed - I'm grateful to you for your time and
>expertise.
>
>
>Best Wishes

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto store date created & updated, EmpId created by and Updated by kay Microsoft Access Form Coding 1 19th Nov 2009 11:55 PM
Enter info in one sheet, auto enter in another based on one field =?Utf-8?B?VGhlIEJ1c3lIaWdoTGlnaHRlcg==?= Microsoft Excel New Users 1 1st Aug 2007 10:54 PM
Auto enter date when data in enter in another cell Brian Microsoft Excel Worksheet Functions 3 7th Dec 2006 06:44 PM
Auto-Enter Data from One Sheet to Another =?Utf-8?B?Q2hyaXN0b3BoZXIgaW4gQmVsbGVmb250YWluZQ== Microsoft Excel Misc 4 24th Apr 2005 03:57 AM
Excel Date - Auto enter file creation date (free chocolate for help) arielax Microsoft Excel Misc 6 29th Apr 2004 02:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:58 PM.