+ Reply to Thread
Results 1 to 3 of 3

VBA to time stamp cells whose values are derived from a data validation dropdown list

Hybrid View

  1. #1
    Registered User
    Join Date
    03-27-2016
    Location
    Tampa,Florida
    MS-Off Ver
    2010
    Posts
    5

    VBA to time stamp cells whose values are derived from a data validation dropdown list

    Hello!
    I have searched the web for an answer with absolutely no luck. I am looking for a code I can put in that will time stamp my "Time Seen" column (column H) when and an option in my drop down list "Seen By" (column G) is chosen.

    I currently use a code (attached) that time stamps my "Check In" column (column A) when a name is put into the "Full name" column (column B). This code does not work when I select a dropdown option vs the manual input that I do for names
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Re: VBA to time stamp cells whose values are derived from a data validation dropdown list

    Natures_Gift,

    Col G of attached has DropLists with three options - Person 1, Person 2 and Person 3

    If you select "Person 2" in any row, Col H of that row is 'time stamped' as "HH:MM:SS", If you want it to show Date as well, change the format of the Column.

    Code as follows:

    Option Explicit
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    'Do nothing if more than one cell is changed or content deleted
    
       If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
          
    'Set Macro to work only on column G
            If Not Intersect(Target, Range("G:G")) Is Nothing Then
    
     'Stop any possible runtime errors and halting code
    
                On Error Resume Next
    
    'Turn off ALL events so the change does not put the code into a loop.
    
                    Application.EnableEvents = False
    
    'ENter time in Col H if specific option chosen
    
                If Target = "Person 2" Then  ' CHANGE THIS TO WHATEVER IT IS YOU WANT TO TRIGGER THE TIMESTAMP
                Target.Offset(0, 1) = Now
                End If
                
    'Turn events back on
    
                    Application.EnableEvents = True
    
    'Allow run time errors again
    
                On Error GoTo 0
    
            End If
    
    End Sub
    Obviously you will change the Data Validation List and "specific" trigger choice to whatever you want. Just change the Macro line accordingly

    Hope this helps

    Ochimus
    Attached Files Attached Files
    Last edited by Ochimus; 03-27-2016 at 05:09 PM.

  3. #3
    Registered User
    Join Date
    03-27-2016
    Location
    Tampa,Florida
    MS-Off Ver
    2010
    Posts
    5

    Post Re: VBA to time stamp cells whose values are derived from a data validation dropdown list

    THANK YOU! It worked, however, another code i had in there no longer works i have never never tried multiple codes. Also if i have multiple options in my drop down do i just repeat this portion of the code:
    'ENter time in Col H if specific option chosen
    
                If Target = "Person 2" Then  ' CHANGE THIS TO WHATEVER IT IS YOU WANT TO TRIGGER THE TIMESTAMP
                Target.Offset(0, 1) = Now
                End If
                
    'Turn events back on
    
                    Application.EnableEvents = True
    
    'Allow run time errors again
    
                On Error GoTo 0
    Attached is the spreadsheet i am working on. I am on the walk ins tab i am trying to auto stamp with time when the correlating columns have data in them:

    Walk ins sheet:

    Time stamp Column A when data is in Column B
    Time stamp Column H when data is in Column G (drop down)
    Time stamp Column J when data is in Column I (drop down)

    Appointments sheets
    Time stamp Column F when data is in Column D (drop down)
    Time stamp Column H when data is in Column G (drop down)
    Time stamp Column J when data is in Column I (drop down)
    Attached Files Attached Files
    Last edited by vlady; 03-27-2016 at 09:09 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Select item of a dropdown list (data validation) and refreshes values of all pivot tables
    By siroco79 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-06-2014, 05:35 AM
  2. Replies: 0
    Last Post: 10-16-2013, 11:01 AM
  3. Validation rule dropdown list without duplicate values
    By sakinen in forum Excel General
    Replies: 9
    Last Post: 05-08-2013, 08:56 AM
  4. Dropdown List/Data Validation
    By ScabbyDog in forum Excel General
    Replies: 7
    Last Post: 03-14-2013, 08:01 AM
  5. Unique list of records dropdown in Data Validation list
    By sghosh12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 08:27 AM
  6. Selecting a value from a dropdown list (data validation) which will populate cells..
    By milkychips in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2012, 09:07 PM
  7. Replies: 7
    Last Post: 02-18-2012, 06:01 AM
  8. Dropdown list (Data>Validation)
    By mc515 in forum Excel General
    Replies: 1
    Last Post: 11-22-2007, 09:43 AM

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