Hi VBA experts,
I know there are many existing codes on updating comments online, but i am just not fit enough to change those macros to suit my needs. What i am looking for is something similar to this code below (found here: http://www.mrexcel.com/forum/excel-q...t-comment.html), but with multiple ranges such as A:B, D:G, T:Z
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oComment As comment, cell As Range, strPrev As String
If Not Intersect(Target, Columns("A:B")) Is Nothing Then
For Each cell In Intersect(Target, Columns("A:B"))
Set oComment = Nothing
On Error Resume Next
Set oComment = cell.comment
On Error GoTo 0
If Not oComment Is Nothing Then
strPrev = Mid(oComment.Text, InStr(oComment.Text, "Current value: ") + 15, 999)
oComment.Text Text:="Previous value: " & strPrev & Chr(10) & _
"Changed: " & Format(Now, "mmm dd, yyyy h:mm AM/PM") & Chr(10) & _
"Current value: " & cell.Value
ElseIf Not IsEmpty(cell) Then
cell.AddComment
cell.comment.Text Text:="Previous value: Empty" & Chr(10) & _
"Changed: " & Format(Now, "mmm dd, yyyy h:mm AM/PM") & Chr(10) & _
"Current value: " & cell.Value
cell.comment.Shape.Width = 150
cell.comment.Shape.Height = 35
End If
Next cell
End If
End Sub
However, what I would additionally need is an input box, which enables me to enter the comment (without deleting previous comments) when a cell is changed. So in the end, each comment entered into a specific cell in this range would be in the cell that was changed along with the date and time when the comment was edited/created. Is that possible?
Hope you understand what I mean
Thanks a lot
Bookmarks