Results 1 to 3 of 3

Auto Insert Date and Time - When any Text is entered in to cell

Threaded View

  1. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Auto Insert Date and Time - When any Text is entered in to cell

    Hi Sanu,

    Ok, edited code below, should be ok now...


    Open VBA editor, double-click on the name of the sheet you want to use the macro on, and then paste the following code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim rngDataRange As Range
        Dim rownum As Long
        Set rngDataRange = Range("H1:H1000") 'Enter range(s) that should be monitored
        Application.ScreenUpdating = False
        If Not Intersect(Target, rngDataRange) Is Nothing Then
            Application.EnableEvents = False 'Prevent following code from triggering events
            'Code to do what is desired when range is activated goes below
            rownum = Target.Row
            If Target.Value = "" Then
                Cells(rownum, 4).Value = ""
                Cells(rownum, 5).Value = ""
            End If
            If Target.Value <> "" Then
                If Cells(rownum, 4).Value = "" Then Cells(rownum, 4).Value = Date
                If Cells(rownum, 5).Value = "" Then Cells(rownum, 5).Value = Time
            End If
        End If
        Set rngDataRange = Nothing
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End Sub
    Last edited by Arkadi; 07-11-2014 at 08:40 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Auto date/time insert when data entered into an adjacent cell
    By Max in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 12:05 PM
  2. [SOLVED] Auto date/time insert when data entered into an adjacent cell
    By Max in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 06:05 AM
  3. [SOLVED] Auto date/time insert when data entered into an adjacent cell
    By Auto date/time in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  4. Auto date/time insert when data entered into an adjacent cell
    By Auto date/time in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  5. Auto date/time insert when data entered into an adjacent cell
    By Auto date/time in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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