Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Automatic date entry

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there a way to automatically enter a date into a worksheet. I have a sheet with the date in coloumn D. What I would like is a way of the date being entered as soon as a value is entered into column A.

    Unfortunately, I also need that date to stay permanently even if the original entry in A is edited at a later date.

    For example a salesman could bring a deal into the office and it could be logges in the sheet. If that salesman leaves or if another salesman amends the deal resulting in a different name being entered into A I don't want the original date in D to change.

    Is it possible?

    Dave

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi --

    Do you require Code VBA or formula

    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    New Member
    Join Date
    Mar 2002
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Either would do Jack.

    VBA would be interesting as I am trying to get into that more.

    Thanks in anticipation.

    Dave

  4. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You could right click on the sheet in question, click view code and enter the following vba:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Columns(1)) Is Nothing Then
        If Target.Offset(, 3).Value = Empty _
        And Target <> "" Then
        Target.Offset(, 3).Value = Date
        End If
    End If
    End Sub
    You must make sure your events are enabled. Hope this helps.


  5. #5
    New Member
    Join Date
    Mar 2002
    Posts
    21
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    In the Worksheet module for the concerned sheet, insert the following code:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Col = Target.Column
    Dim Temp As Range
    If Col = 1 Then
    Set Temp = Target.Offset(0, 3) 'For col. D:D
    If IsEmpty(Temp) Then Temp = Now()
    Temp.NumberFormat = "mmm dd, yyyy" 'Or whatever date format you like
    End If
    End Sub


    or the other way can be:

    Option Explicit

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Column = 1 Then
    If Target.Offset(0, 3).Text = "" Then
    Target.Offset(0, 3).Value = Now
    End If
    End If
    End Sub


  6. #6
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    So many ways to skin a cat )

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 And Not IsDate(Target(1, 4)) Then
    Target.Cells(1, 4) = Date
    End If
    End Sub

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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