+ Reply to Thread
Results 1 to 2 of 2

timestamp column not populated

  1. #1
    Registered User
    Join Date
    06-17-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    1

    timestamp column not populated

    Hi Listers,

    I came across some code that creates a timestamp column. I don’t know VB/VBA @ all and work extensively with TSQL, nonetheless it wasn’t too difficult to piece the concept together.

    The code worked perfectly when the worksheet was open, ie. the timestamp field was updated when one particular field was updated, however, when I attempted to insert data into the particular worksheet thru SQL Server’s Integration Services (using data flow that writes exception records to an Excel destination), the records get written but the timestamp column remains blank.

    Here is the the worksheet code:
    >>>>>>
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column <> 2 Then Exit Sub
    If IsEmpty(Target(1)) Then Exit Sub '-- also rejects if entire row cleared
    If Target.Row = 1 Then Exit Sub
    If IsEmpty(Target.Offset(0, 24)) Then
    Target.Offset(0, 24) = Date
    'Target.Offset(0, 24).NumberFormat = "dd-mm-yyyy hh:mm:ss"
    Target.Offset(0, 24).Value = Now
    End If
    End Sub
    <<<<<<
    Could you explain what may be happening and how I might rectify this unusual behaviour, or direct me to a link that cold resolve my issue?

    Many thanks in advance.

  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

    Re: timestamp column not populated

    When you add to a sheet via code the Worsheet_change event isn't triggered, you will need to write the timestamp sequence in to your SQL, if you are opening the workbook the best you could probably do is timestamp everything that has a value in coulmn b but a blank in the offset where you want your stamp.
    Not all forums are the same - seek and you shall find

+ 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