+ Reply to Thread
Results 1 to 7 of 7

Code for a timestamp.

  1. #1
    Registered User
    Join Date
    05-11-2007
    Location
    A hole in the US.
    Posts
    29

    Code for a timestamp.

    Hello, im new to the forum, so excuss my ignorance if I make any typos. I am creating a Excel worksheet and need a code to allow a one time timestamp. For example: If I want B1 to display the time that A1's value goes to anything above 1, I put: If(A1>0,NOW(),""). The only thing wrong with that equation is that the time changes everytime something is changed on the sheet. I need the time to stay once its been put in there. I have been told that this may not be possible with Excel, but thats why im on the forum now. If anyone can help that would be greatly appretiated.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444
    Hi,

    This need to go in the VB editor.

    Press ALT & F11 to open the VB editor
    In the pane on the left, double click the worksheet you need to work on
    A dropdown menu will appear that is defaulted to General - change it to worksheet and the following should appear:-

    Please Login or Register  to view this content.
    Copy and paste so that it looks like this:

    Please Login or Register  to view this content.
    You can change this to suit - but at the moment it looks at cell B1, and as soon as it has a value greater than 1, puts the time and date into cell A1
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    05-11-2007
    Location
    A hole in the US.
    Posts
    29
    Dude that worked great, thanks man. So in order to do it for a whole column I just do something like.

    Private Sub Worksheet_Activate()
    Dim test As Variant
    Static runtest As Variant
    Please Login or Register  to view this content.


    I just tried that and it widnt work, how might I word it to make it do an entire column.
    Last edited by VBA Noob; 05-12-2007 at 03:21 AM.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Zirus

    Welcome to excelforum

    Please read forum rules & wrap your VBA code
    See blue link below for forum rules
    See red link below for instructions on wrapping your code
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  5. #5
    Registered User
    Join Date
    05-11-2007
    Location
    A hole in the US.
    Posts
    29
    Ok I wrapped the code like the instructions said. It still works the same way, and I believe I followed the rules as described. If I have not please let me know so that I may correct the problem in the future.

    here is the code that I have so far.

    Please Login or Register  to view this content.
    Is there a way(other than repeating the code) to make the process work from "C10" to "C110"? Again sry for the misshap on the posting rules.

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Zirus

    In your previous post your VBA code is wrapped correctly - thank you

    Now to your problem

    I am supplying 2 macros
    Macro 1 is if c10 to c110 are values - not formulas
    Macro 2 is if c10 to c110 are formulas

    Place one of the macros on same sheet as your worksheet change macro


    Macro 1
    Please Login or Register  to view this content.
    Macro 2
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-11-2007
    Location
    A hole in the US.
    Posts
    29

    Smile

    Great that seems to work just how that I wanted it to. I appreciate everything.

+ 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