Consulting

Results 1 to 6 of 6

Thread: Solved: Date, Month, and Time Stamp using VBA

  1. #1

    Solved: Date, Month, and Time Stamp using VBA

    I am trying to modify a vba code written by s76.vj yesterday to automatically stamp "Time" in column C when column A a item is selected from the drop-down list in column A (this part is working great); I also want the code to automatically stamp "date, month and time" in column F, E and D respectively when an item is selected from the drop-down list in column G (Received By -title heading) - this is one part the code is not able to capture.

    I believe that the code will need to be modified to capture the "date, month and time" in column F, E and D respectively when an item is selected from the drop-down list in column G.

    I need assistance in modifying the code to stamp date, month, and time separately in column F, E and D respectively. [B]Below is the code:

    Note: I have attached a sample copy of the template.

    [VBA]Private Sub Worksheet_Change(ByVal Target As Excel.Range)

    With Target

    If .Count > 1 Then Exit Sub

    If .Column <> 1 And .Column <> 6 Then Exit Sub
    Application.EnableEvents = False
    If .Column = 1 Then
    If IsEmpty(.Value) Then

    .Offset(0, 2).ClearContents
    Else

    With .Offset(0, 2)

    .NumberFormat = "dd mmm yyyy hh:mm:ss"
    .Value = Now
    End With
    End If
    ElseIf .Column = 6 Then

    If IsEmpty(.Value) Then

    .Offset(0, -1).ClearContents
    .Offset(0, -2).ClearContents
    Else

    With .Offset(0, -2)

    .NumberFormat = "hh:mm:ss"
    .Value = Now
    End With

    With .Offset(0, -1)

    .NumberFormat = "dd mmm yyyy"
    .Value = Now
    End With
    End If
    End If

    Application.EnableEvents = True
    End With
    End Sub[/VBA]
    Attached Files Attached Files
    Last edited by Bob Phillips; 02-13-2013 at 03:05 AM. Reason: Added VBA tags

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Please use codetags !

    Why don't you continue your previous thread ?

    Did you use the suggestion I provided in that thread ?

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This looks like the same question that you asked yesterday, and you had two suggestions to solve the problem there.

    Unless you give me a good reason not to, I will delete this at 1r4:00 GMT.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    Thank you for the response. This particular problem is expand on the initial problem that was posted two (2) days ago. The initial problem did not have to stamp month, date and time when selecting an item in the "Received By" column.

    Thanks much.


    Quote Originally Posted by xld
    This looks like the same question that you asked yesterday, and you had two suggestions to solve the problem there.

    Unless you give me a good reason not to, I will delete this at 1r4:00 GMT.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is not a new request, just a slight modification, so update the other post to reflect that an in the light of those responses. Otherwise we think we are wasting our time trying to help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    xld, it is alright to remove this thread as I now have it posted in the initial problem.

    Thanks much for your time.

Posting Permissions

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