Avatar of Steve_Brady
Steve_Brady
Flag 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
Microsoft Excel

Avatar of undefined
Last Comment
Steve_Brady

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dlmille

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
byundt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Steve_Brady

ASKER
Many thanks
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck