+ Reply to Thread
Results 1 to 8 of 8

Cannot get timestamp to work with macro correctly

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question Cannot get timestamp to work with macro correctly

    I'm really new to VBA macros, but not completely new to programmning. What I am trying to accomplish is to timestamp a date to on cell G1 at any time that any data is added, changed, removed from anywhere on the sheet. I have come up with a couple solutions, but nothing quite right. Can anyone give me a hand? Thanx.
    Last edited by gsx1000r02; 06-07-2012 at 10:39 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Cannot get timestamp to work with macro correctly

    Hello there,

    To achieve this select the tab for the worksheet you want the datestamp to be stamped on when the worksheet is updated.

    Then rightclick on the tab and select View code.

    Paste the below code in the space provided.

    Please Login or Register  to view this content.
    Anything that appears in green is a comment.

    You can then exit out of VBA

    You may need select a new number format for cell G1 to have it correctly display the information. I had to select More Number formats and then the Date category and then 3/14/01 1:30pm.

    Let me know if this works for you!

    Thanks!

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Cannot get timestamp to work with macro correctly

    Quote Originally Posted by rvasquez View Post
    Hello there,
    To achieve this select the tab for the worksheet you want the datestamp to be stamped on when the worksheet is updated.
    Then rightclick on the tab and select View code.
    Paste the below code in the space provided.
    Please Login or Register  to view this content.
    Anything that appears in green is a comment.
    You can then exit out of VBA
    You may need select a new number format for cell G1 to have it correctly display the information. I had to select More Number formats and then the Date category and then 3/14/01 1:30pm.
    Let me know if this works for you!

    Thanks!
    OK I added this code, and nothing happened. I'm starting from scratch and do not know the VB programming terms, seems to me that it doesn't know where to monitor, as if a range needs to be specified.

    My sheet contains columns A2:G1000 and anywhere within this can be updated (rows and data can be added, deleted and changed). Instead of having a new timestamp in the adjacent cell for each row, I need it in a specific cell: G1 to show the last time that anything was touched no matter what it was. The format that is needed is (07 Jun 12 10:59) I'm assuming that the clock will automatically show in a 24 hour format and that's also what I need.

  4. #4
    Registered User
    Join Date
    05-16-2012
    Location
    Utah
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Cannot get timestamp to work with macro correctly

    The above code should work already. What it is saying is if there is a change anywhere in the worksheet, it will paste the timestamp into G1. Are your macros enabled?

  5. #5
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Cannot get timestamp to work with macro correctly

    Could you provide a sample of your worksheet?

    Thanks!

  6. #6
    Registered User
    Join Date
    06-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Cannot get timestamp to work with macro correctly

    OK I don't know what happened but it's working. Why would others that I looked at try to put in sheet ranges, 'if' statements and a whole bunch of other stuff for something this simple? A couple of the codes I looked at were about 20 lines long, and this one is only 4.

    Also, looking at the file types that excel offers, the one that is labeled macro enabled .xlsm kept giving me errors when using a macro. I ended up using the .xls type which is the 97-03 compatibility mode. The .xlsx which is the new version for office 07 also gave me errors with the marco, so i don't know what it's all about.

    Here is the file, I just removed some of the data. It is working like I need it to. Thanx again
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Cannot get timestamp to work with macro correctly

    I'm glad it's working for you. Others codes may have been a little more specific as far as why they wanted the timestamp to change. That would explain if statements and other additions to the code. Your request was pretty simple in the fact that you didn't care what changed, just if anything changed then you wanted the timestamp, makes it a little easier.

    Thanks!

  8. #8
    Registered User
    Join Date
    06-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Cannot get timestamp to work with macro correctly

    Thanks again for your help guys. I think I might just keep this forum around, as I might be doing more with excel and VB here at work. Also, do you guys do anything with access DB here?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1