+ Reply to Thread
Results 1 to 10 of 10

Create comment that updates based off cell change

  1. #1
    Registered User
    Join Date
    03-29-2014
    Location
    Alberta, Canada
    MS-Off Ver
    Excel - Office 365
    Posts
    43

    Create comment that updates based off cell change

    Hello,

    I found a macro for a sheet to add a comment every time a cell is changed, however I need it modified to keep adding comments instead of overwriting the original.

    Here's the current macro:

    Option Explicit
    Public preValue As Variant
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Intersect(Target, Range("$B$22:$B$40")) Is Nothing Then Exit Sub
    Target.ClearComments
    Target.AddComment.Text Text:="Previous Value was " & preValue & Chr(10) & "Revised " & Format(Date, "mm-dd-yyyy") & Chr(10) & "By " & Environ("UserName")
    End Sub

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Intersect(Target, Range("$B$22:$B$40")) Is Nothing Then Exit Sub
    If Target = "" Then
    preValue = "a blank"
    Else: preValue = Target.Value
    End If
    End Sub

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Create comment that updates based off cell change

    eathandbody:

    Please review the forum rules, especially #3 about using code tags? Thanks!

    That aside, try this code:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    03-29-2014
    Location
    Alberta, Canada
    MS-Off Ver
    Excel - Office 365
    Posts
    43

    Re: Create comment that updates based off cell change

    Thanks for the heads up. I did take another look at rule 3.

    The code still overwrites the previous text instead of adding to it.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Create comment that updates based off cell change

    Did you replace the whole change event code with mine? Your original had a clearcomments command which removes old comments. I did test mine and dont lose the old comments.

  5. #5
    Registered User
    Join Date
    03-29-2014
    Location
    Alberta, Canada
    MS-Off Ver
    Excel - Office 365
    Posts
    43

    Re: Create comment that updates based off cell change

    I did and I'm not getting it to work.

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Create comment that updates based off cell change

    Can you post your amended code? Or better yet attach the workbook? You can delete all data if you want first

  7. #7
    Registered User
    Join Date
    03-29-2014
    Location
    Alberta, Canada
    MS-Off Ver
    Excel - Office 365
    Posts
    43

    Re: Create comment that updates based off cell change

    Got the code entered this morning but it's not inputting the number. Its blank.
    Attached Files Attached Files

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Create comment that updates based off cell change

    Oh, yes you still need your original selection_change code in the sheet as well.
    Complete Sheet1 code:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    03-29-2014
    Location
    Alberta, Canada
    MS-Off Ver
    Excel - Office 365
    Posts
    43

    Re: Create comment that updates based off cell change

    Got it. Thank you very much for your help.

  10. #10
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Create comment that updates based off cell change

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA to change cell comment based on cell value
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2016, 05:38 PM
  2. Create a dynamic comment based on values in another sheet
    By kinscy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-16-2016, 08:50 PM
  3. Create a four-column sorting table that updates based on calculations.
    By arwebb0264 in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-13-2016, 03:38 PM
  4. [SOLVED] Change Command Button name/comment based on cell value
    By DHFE in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-19-2015, 06:29 AM
  5. How to create a list that dynamically updates based on other selections
    By DAN.DEJONG84 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-18-2015, 04:58 PM
  6. create comment for cell based on different cells
    By klayman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2014, 10:32 AM
  7. Replies: 3
    Last Post: 03-04-2011, 06:01 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1