+ Reply to Thread
Results 1 to 6 of 6

Insert a comment based on the value of a cell

  1. #1
    Registered User
    Join Date
    01-08-2010
    Location
    Sussex County, Delaware
    MS-Off Ver
    Excel 2013
    Posts
    40

    Insert a comment based on the value of a cell

    Greetings,

    I have data validation and conditional formatting set for my sheets. However, I cannot figure out something.

    I want a "comment" box (just as if I would click on "add comment") to pop up automatically if the user enters a certain value in a cell.

    For example, if cell C4="1" then no further action is required. If cell C4=anything other than "1", then the user would be required to enter a comment. I would also like the comment to autopopulate with the users login id.

    I will attach the book I am working on for reference, but I do not have any code written for this as I could not figure out where to start.

    Any help would be appreciated!
    Attached Files Attached Files
    Last edited by vamedic11; 01-20-2010 at 07:05 PM. Reason: mark solved

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Insert a comment based on the value of a cell

    hi
    try this one HTH

    Please Login or Register  to view this content.
    Place Both these codes in each sheett
    Last edited by contaminated; 01-19-2010 at 01:46 AM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    01-08-2010
    Location
    Sussex County, Delaware
    MS-Off Ver
    Excel 2013
    Posts
    40

    Re: Insert a comment based on the value of a cell

    Hi Vusal,

    I must be doing something wrong. I opened the workbook, pressed [alt-f11] in each sheet, pasted both codes in, and saved the file, but nothing happens.

    Any thoughts?
    Last edited by vamedic11; 01-19-2010 at 10:37 PM.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,602

    Re: Insert a comment based on the value of a cell

    I don't know which worksheet you pasted your code into; however, I have put it in the ThisWorkbook module and modified it slightly to ignore the "DATA" worksheet.
    PHP Code: 
    Private Sub Workbook_SheetChange(ByVal Sh As ObjectByVal Target As Range)
        If 
    Sh.Name "Data" Then Exit Sub
        On Error 
    GoTo errorout   'Resume Next
        If Target = 1 Then
            With Target
                .AddComment
                .Comment.Text Text:=Application.UserName & ":" & Chr(10)
                .Comment.Visible = True
            End With
        End If
    errorout:
        Err.Clear
    End Sub
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
        If Sh.Name = "Data" Then Exit Sub
        
        Dim MyShp       As Comment, _
            CommentList As Comments
            
        Set CommentList = Sh.Comments
        For Each MyShp In CommentList
            MyShp.Visible = False
        Next MyShp

    End Sub 
    Attached Files Attached Files
    Ben Van Johnson

  5. #5
    Registered User
    Join Date
    01-08-2010
    Location
    Sussex County, Delaware
    MS-Off Ver
    Excel 2013
    Posts
    40

    Re: Insert a comment based on the value of a cell

    Hi Ben, and thank you!

    After working it, it looked GREAT...until I protected the sheets!!!

    I suspect that adding comments, even to unlocked cells, is not possible in Excel 2007. Would I be correct?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Insert a comment based on the value of a cell

    Quote Originally Posted by vamedic11 View Post
    Hi Ben, and thank you!

    After working it, it looked GREAT...until I protected the sheets!!!

    I suspect that adding comments, even to unlocked cells, is not possible in Excel 2007. Would I be correct?
    Answered here:

    http://www.excelforum.com/excel-work...worksheet.html
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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