+ Reply to Thread
Results 1 to 9 of 9

Date Problem

Hybrid View

  1. #1
    Registered User
    Join Date
    03-04-2008
    Posts
    32

    Date Problem

    I have a workbook with various cells that are either 0,1 or 2 in a dropdown, what I would like is that when these are changed then the next cell would add teh date/time Now() function.

    This would have to be done for individual cells as they are not in groups

    I.E. j2, g5, k56 etc

    Any help wold be appreciated

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    If you use the Now() function everytime a worksheet recalculates so will Now, do you mean that you want the cell time and date stamped and not change when other cells are changed?
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    Simon
    That is correct, all thats needed is that say when J46 is changed then J47 has the date time stamp.

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    In that case try this, right click the worksheet tab you are using choose view code and paste the below in:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("E2,G4,I1,K23")) Is Nothing Then ' you get the idea for adding cells
    Select Case Target.Value' check the value of the cell you are in
              Case 0' if 0 then time stamp
                 Target.Offset(0, 1).Value = Format(Date, "dd/mm/yyyy - hh:mm")
              Case 1' if 1 time stamp
                  Target.Offset(0, 1).Value = Format(Date, "dd/mm/yyyy - hh:mm")
              Case 2' ...etc
                 Target.Offset(0, 1).Value = Format(Date, "dd/mm/yyyy - hh:mm")
              
              'just continue the list like this for more figures if needed
        End Select
    End If
    End Sub

  5. #5
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    Simon

    Many thanks, but there are a couple of problems.
    1. This does not offset the date/time it puts it in the same cell.
    2. it shows the date time as 00/01/1900 00:00:00 wrong date time etc

    Rgds

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    This works for me:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("E2,G4,I1,K23")) Is Nothing Then ' you get the idea for adding cells
    Select Case Target.Value
              Case 0
                 Target.Offset(0, 1).Value = Format(Now(), "dd/mm/yyyy - hh:mm")
              Case 1
                  Target.Offset(0, 1).Value = Format(Now(), "dd/mm/yyyy - hh:mm")
              Case 2
                 Target.Offset(0, 1).Value = Format(Now(), "dd/mm/yyyy - hh:mm")
              
              'just continue the list like this
        End Select
    End If
    End Sub

  7. #7
    Registered User
    Join Date
    03-04-2008
    Posts
    32
    Simon

    Thanks that works a treat, the only problem is that the time changes everytime I click in the cell, I only want this to happen when the cell is changed..

    Many thanks

+ 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