Link to home
Start Free TrialLog in
Avatar of Steve_Brady
Steve_BradyFlag for United States of America

asked on

Can't get Excel VBA from another thread to function properly.

Hello,

This is a follow-up to another thread here:

          Automated date & time stamping in Excel

The gist of the other thread was to find a way to:

a) automatically have a Date & Time stamp appear (with the current date and time) in column A whenever any type of entry is made in column B in the corresponding row,
          AND
b) have the Date & Time remain static or fixed so, for example, the date and time the entry was made can be ascertained even if one is looking at the spreadsheet after the fact.

The solution included the following code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range
    If Target.Column = 2 Then
        For Each cl In Target.Cells
            cl.Offset(, -1).Value = Now
        Next cl
    End If
End Sub

Open in new window

with instructions to:

          "Put this in the module of the worksheet you want to add the timestamp to."

I'm doing something wrong because I'm not getting the Date & Time stamps I anticipated. Here's what I did:

          1) opened a brand-new workbook and opened Visual Basic
          2) in Visual Basic > Insert menu > Module
          3) pasted the above code in the module
          4) Save As an .xlsm (macro-enabled) file
          5) began making entries in column B

If someone could give me a brief explanation of what I am missing and how to make the code functional, I would appreciate it.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of dlmille
dlmille
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of byundt
byundt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve_Brady

ASKER

Many thanks