Consulting

Results 1 to 8 of 8

Thread: Solved: Track Changes in Comment

  1. #1
    VBAX Regular
    Joined
    Nov 2007
    Posts
    9
    Location

    Solved: Track Changes in Comment

    Hi Guys,
    I've been reading though various threads all day and can't quite seem to find one that does what I need: I want to track the changes to cells in a spreadsheet using the Add Comment. I want to see the previous value, date it was changed and name of user that changed it; for example, if the previous value is 15% and I change it to 18%, I want the comment to show: 15%, 7/6/09, karrims. In addition, I do not want it to delete the previous comment, just add to it. Clear as mud?!?

    Thanks,
    karrims

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private mcPrev As Variant
    Const WS_RANGE As String = "H1" '<== change to suit

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address(False, False) = WS_RANGE Then

    mcPrev = Target.Text
    End If
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit
    Application.EnableEvents = False

    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    With Target

    If .Comment Is Nothing Then

    .AddComment "Previous values" & Chr(10)
    .Comment.Shape.TextFrame.Characters(1, 999).Font.Bold = True
    .Comment.Shape.TextFrame.AutoSize = True
    Else

    .Comment.Text .Comment.Text & mcPrev & ", " & Format(Date, "m/d/yy") & "," & Environ("Username") & Chr(10)
    .Comment.Shape.TextFrame.Characters(16, 999).Font.Bold = False
    .Comment.Visible = False
    End If
    End With
    End If

    ws_exit:
    Application.EnableEvents = True

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Nov 2007
    Posts
    9
    Location

    Talking

    This is why I love you guys!!! Thank you!!!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I had implemented this self-same idea for one of my clients recently, so I already had it in my back pocket
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    This code works great for single cell.
    Can we modify this for range of cells like A150

    I tried to modify this line as stated from

    [VBA]Const WS_RANGE As String = "H1" '<== change to suit[/VBA]

    to

    [VBA]Const WS_RANGE As String = "A150" '<== change to suit[/VBA]

    it worked fully except catching old text (now it is not able to store old value in cell).

    pl help
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Yes, iterate through the range of Target and process each cell.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Mentor anandbohra's Avatar
    Joined
    May 2007
    Location
    Mumbai
    Posts
    313
    Location
    pl explain how to achieve the same
    Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
    Practice this & save time of others in thinking for unsolved thread

  8. #8
    VBAX Regular
    Joined
    Oct 2009
    Posts
    9
    Location

    Red face

    Quote Originally Posted by anandbohra
    pl explain how to achieve the same
    Makes two of us noobs...

    I would like to see how to do it for a:
    1. Range
    2. Column
    3. Entire worksheet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •