Hi,
I am having the fun task of converting some Google sheets to Excel sheets, the google sheets have some javascript with that I need to change to VBA to enable the functionality in the final excel sheet.
I am looking to do some thing simple really, when someone enters a value into Col A I want a time stamp to appear in Col M, that part is fine, I also want to have in Col J a comment added with a time stamp when something is added to the cell. I have the first part sorted but I am trying to do the second.
The code issue is dealing with a range for the entry in ColJ, I currently have a set cell J7 that works but I want it to work for all of ColJ.
You can see i initially wanted to repeat the action of the Target usage but that doesn't work, also I needed to change the action from adding full text to a into a comment.
Could you please give me advice or show me what I should do, once i see trhat correct options I should be able to understand for reuse.
Thanks
I am having the fun task of converting some Google sheets to Excel sheets, the google sheets have some javascript with that I need to change to VBA to enable the functionality in the final excel sheet.
I am looking to do some thing simple really, when someone enters a value into Col A I want a time stamp to appear in Col M, that part is fine, I also want to have in Col J a comment added with a time stamp when something is added to the cell. I have the first part sorted but I am trying to do the second.
The code issue is dealing with a range for the entry in ColJ, I currently have a set cell J7 that works but I want it to work for all of ColJ.
You can see i initially wanted to repeat the action of the Target usage but that doesn't work, also I needed to change the action from adding full text to a into a comment.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Handler
'Add Timestamp to ColM
If Target.Column = 1 And Target.Value <> "" Then
Application.EnableEvents = False
Target.Offset(0, 12) = Format(Now(), "dd-mmm-yyyy hh:mm:ss")
Application.EnableEvents = True
End If
'Add Timestamp to ColJ - Needs fixing
''If Target.Column = 10 And Target.Value <> "" Then
' Application.EnableEvents = False
'Here is where I need to add and integrate the AddComment
' Target.Offset(0, 0) = ActiveCell.AddComment.Text(myTime)
' Application.EnableEvents = True
'End If
Dim myTime As Variant
myTime = Format(Now(), "dddd,d-mmm-yyyy hh:mm:ss")
Range("J7").Select
ActiveCell.AddComment.Text (myTime)
Handler:
End Sub
Could you please give me advice or show me what I should do, once i see trhat correct options I should be able to understand for reuse.
Thanks