Assigning a VBA to a specific column.

JEH105

New Member
Joined
Oct 11, 2019
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I'm not very experienced in VBA, but I found the following code in order to add time stamps to a workbook. However, I need the timestamps to be added to column D only. Currently, it applies the timestamps to ALL cells. Here is the code:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

With Target

If Not IsEmpty(.Value) Then

' Jack Clears the comment.

.ClearComments

' Jack Creates the comment.

.AddComment (Application.UserName & " ; " & Date & " ;" & Time)

' Can have user name in top left by adding name between ""

.Comment.Visible = False



Else: .ClearComments

End If

End With



End Sub

I appreciate any help you can provide! :)
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Give this Change event code a try...
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Cell As Range
  On Error GoTo NothingInColumnD
  For Each Cell In Intersect(Target, Columns("D"))
    With Cell
      If .Column = 4 Then
        .ClearComments
        If Len(.Value) Then
          .AddComment Application.UserName & " ; " & Date & " ;" & Time
          .Comment.Visible = False
        End If
      End If
    End With
  Next
NothingInColumnD:
End Sub
 
Upvote 0
Solution
Thank you so much! This is exactly what I needed. I appreciate your help at this time! :)
 
Upvote 0

Forum statistics

Threads
1,214,848
Messages
6,121,914
Members
449,054
Latest member
luca142

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top