+ Reply to Thread
Results 1 to 8 of 8

date/time stamp

  1. #1
    Jan
    Guest

    date/time stamp

    I know I probably did post my reply correctly to get a possible solution to
    my problem. Any further help would be greatly appreciated.


    Sorry, but I failed to mention the process correctly. If end user enters
    data in any cell in column A beginning at cell a2, then I would like the
    corresponding cell(same row) in column B to have a date/time stamp that would
    not change when the date/time changes or when the file is saved and reopened.
    Example: if user enters data in cell A2, then B2 would automatically display
    date/time stamp. If user enters data in cell A3, then B3 would have a
    date/time stamp...and so on..and so on. TIA.

    -----------------------------------------------

    Enter this code in the module of the concerned sheet.
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
    Range("B1") = Now()
    End If
    End Sub

    Will change the date only when you change or enter value in A1
    Mangesh

    ________________________________________

    I'm using Excel 2003.

    Is this possible?

    If end user enters data in A1, can I add a date/time function that will
    automatically be entered in cell B1, but not update when the date/time
    changes or when the file is closed/opened? Using Today() or Now(), the
    date/time in B1 updates when file is closed and then opened.

    TIA


  2. #2
    Bob Phillips
    Guest

    Re: date/time stamp

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("A:A")) Is Nothing Then
    With Target
    .Offset(0, 1).Value = Time
    .Offset(0, 1).NumberFormat = "hh:mm:ss"
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.




    --
    HTH

    Bob Phillips

    "Jan" <[email protected]> wrote in message
    news:[email protected]...
    > I know I probably did post my reply correctly to get a possible solution

    to
    > my problem. Any further help would be greatly appreciated.
    >
    >
    > Sorry, but I failed to mention the process correctly. If end user enters
    > data in any cell in column A beginning at cell a2, then I would like the
    > corresponding cell(same row) in column B to have a date/time stamp that

    would
    > not change when the date/time changes or when the file is saved and

    reopened.
    > Example: if user enters data in cell A2, then B2 would automatically

    display
    > date/time stamp. If user enters data in cell A3, then B3 would have a
    > date/time stamp...and so on..and so on. TIA.
    >
    > -----------------------------------------------
    >
    > Enter this code in the module of the concerned sheet.
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > If Target.Address = "$A$1" Then
    > Range("B1") = Now()
    > End If
    > End Sub
    >
    > Will change the date only when you change or enter value in A1
    > Mangesh
    >
    > ________________________________________
    >
    > I'm using Excel 2003.
    >
    > Is this possible?
    >
    > If end user enters data in A1, can I add a date/time function that will
    > automatically be entered in cell B1, but not update when the date/time
    > changes or when the file is closed/opened? Using Today() or Now(), the
    > date/time in B1 updates when file is closed and then opened.
    >
    > TIA
    >




  3. #3
    Jan
    Guest

    Re: date/time stamp

    Bob,

    I tried to adapt the number format so that date and time display because I
    need to have both. I have replaced your " "hh:mm:ss" with ""mm/dd/yy h:mm
    AM/PM;@".
    However, no matter what format I try to use the date displays as 01/0/1900.
    Do you have any suggestions to the the date display as the current date?


    "Bob Phillips" wrote:

    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range("A:A")) Is Nothing Then
    > With Target
    > .Offset(0, 1).Value = Time
    > .Offset(0, 1).NumberFormat = "hh:mm:ss"
    > End With
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >
    > 'This is worksheet event code, which means that it needs to be
    > 'placed in the appropriate worksheet code module, not a standard
    > 'code module. To do this, right-click on the sheet tab, select
    > 'the View Code option from the menu, and paste the code in.
    >
    >
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > "Jan" <[email protected]> wrote in message
    > news:[email protected]...
    > > I know I probably did post my reply correctly to get a possible solution

    > to
    > > my problem. Any further help would be greatly appreciated.
    > >
    > >
    > > Sorry, but I failed to mention the process correctly. If end user enters
    > > data in any cell in column A beginning at cell a2, then I would like the
    > > corresponding cell(same row) in column B to have a date/time stamp that

    > would
    > > not change when the date/time changes or when the file is saved and

    > reopened.
    > > Example: if user enters data in cell A2, then B2 would automatically

    > display
    > > date/time stamp. If user enters data in cell A3, then B3 would have a
    > > date/time stamp...and so on..and so on. TIA.
    > >
    > > -----------------------------------------------
    > >
    > > Enter this code in the module of the concerned sheet.
    > > Private Sub Worksheet_Change(ByVal Target As Range)
    > > If Target.Address = "$A$1" Then
    > > Range("B1") = Now()
    > > End If
    > > End Sub
    > >
    > > Will change the date only when you change or enter value in A1
    > > Mangesh
    > >
    > > ________________________________________
    > >
    > > I'm using Excel 2003.
    > >
    > > Is this possible?
    > >
    > > If end user enters data in A1, can I add a date/time function that will
    > > automatically be entered in cell B1, but not update when the date/time
    > > changes or when the file is closed/opened? Using Today() or Now(), the
    > > date/time in B1 updates when file is closed and then opened.
    > >
    > > TIA
    > >

    >
    >
    >


  4. #4
    JE McGimpsey
    Guest

    Re: date/time stamp

    First, note that the macro as written will give undesired results if a
    multiple selection includes more than one column, including column A.
    For instance, if A1:J10 is selected with C5 active, and C5 is changed by
    the user, all the cells in B1:K10 will be overwritten with the date
    stamp. One way to handle that would be to abort if there's a multiple
    selection.

    Second, Time only returns the time. For dates as well, use Now instead.

    I might amend the macro like this:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rSelect As Range
    With Target
    If .Count > 1 Then Exit Sub
    If Not Intersect(.Cells, Me.Range("A:A")) Is Nothing Then
    Application.EnableEvents = False
    With .Offset(0, 1)
    .Value = Now
    .NumberFormat = "dd/mm/yy hh:mm AM/PM"
    End With
    End If
    End With
    ws_exit:
    Application.EnableEvents = True
    End Sub



    In article <[email protected]>,
    Jan <[email protected]> wrote:

    > I tried to adapt the number format so that date and time display because I
    > need to have both. I have replaced your " "hh:mm:ss" with ""mm/dd/yy h:mm
    > AM/PM;@".
    > However, no matter what format I try to use the date displays as 01/0/1900.
    > Do you have any suggestions to the the date display as the current date?


  5. #5
    JE McGimpsey
    Guest

    Re: date/time stamp

    Oops. Delete the Dim rSelect As Range line (it was from a different
    worksheet_change procedure that I use).

    In article <[email protected]>,
    JE McGimpsey <[email protected]> wrote:

    >
    > I might amend the macro like this:
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > Dim rSelect As Range


  6. #6
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252
    Is there a way to make it so that its "if the value of the cell changes" not "if its double clicked"??

    Also, I would like to protect and hide those cells in the worksheet and not allow the users to edit or even see those date/times. Problem is when I protect the cells and they enter the data in cell a1 or whatever, it doesnt change the date/time cause well.... they're not allowed to change it so it doesn't do the change.
    Last edited by DKY; 07-13-2005 at 12:54 PM.

  7. #7
    JE McGimpsey
    Guest

    Re: date/time stamp

    Take a look here:

    http://www.mcgimpsey.com/excel/timestamp.html


    In article <[email protected]>,
    DKY <[email protected]> wrote:

    >
    > Is there a way to make it so that its "if the value of the cell changes"
    > not "if its double clicked"??
    >
    > Also, I would like to protect and hide those cells in the worksheet and
    > not allow the users to edit or even see those date/times. Problem is
    > when I protect the cells and they enter the data in cell a1 or
    > whatever, it doesnt change the date/time cause well.... they're not
    > allowed to change it so it doesn't do the change.


  8. #8
    Forum Contributor
    Join Date
    09-19-2004
    Posts
    252
    From what I've noticed, the URL above does the same thing. It changes the value of the date/time when you just double click the cell as well as when you change the data in the cell. I just want it to adjust the date/time when you change the data in the first cell, and not when you double click it. I couldn't find any information about that on that URL. I must have missed it. That second set of code in the URL loses me. It says you can apply it to a toolbar or a button? I can't imagine how one would do that because I'm so new and there isn't really any explanation, it must be for the more advanced users

    So here's my code then (that I stole from this site and revised to fit my needs).

    Please Login or Register  to view this content.
    How would I go about adding the windows log-on username to this? I found this

    http://blogs.officezealot.com/charle...2/10/3574.aspx

    Which says you can use this

    Please Login or Register  to view this content.
    But where do I put the function in the code and how do I call it to use?
    Last edited by DKY; 07-14-2005 at 08:12 AM.

+ 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