Solved

Populate cell and cell comment

Posted on 2014-03-13
6
361 Views
Last Modified: 2014-03-14
Hello. Is it possible to populate the cell comment from VLOOKUP? The VLOOKUP in the sample file attached works fine, but some of the text is too much for the cell. Also the cell populated from the VLOOKUP does not have to be printable hence my reasoning of trying to populate it as a comment rather. Thanks
Book2-SAMPLEv2.xls
0
Comment
Question by:zerog
  • 3
  • 3
6 Comments
 

Author Comment

by:zerog
ID: 39925948
Been trying this. It adds the comment, but it doesn't show the text "Check comment" in Q2. Also how would I do this for a range as there are many rows and it's messy to execute a macro for every row manually one at a time. Thanks

Sub testcomment()
    [Q2].AddComment
    [Q2].Comment.Text "Check comment" & Format([M2])
End Sub

Open in new window

0
 

Author Comment

by:zerog
ID: 39926374
Found this piece of code on the internet. It's more advanced than the one quoted in my earlier post. It populates the comment for a specific cell. How do I get it to show some text e.g. "Check Comment" in the cell to guide the user so that they know they have to click to view the comment.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

   Dim Cell As Range

   If Intersect([M2:M10], Target) Is Nothing Then
      On Error Resume Next
      For Each Cell In [M2:M10]
         Cell.Comment.Delete
      Next Cell
   Else
      For Each Cell In Intersect([M2:M10], Target)
         If Len(Me.Cells(Cell.Row, "O").Value) > 0 Then
            On Error Resume Next
            Cell.Comment.Delete
            On Error GoTo 0
            Cell.AddComment Me.Cells(Cell.Row, "O").Value
         End If
      Next Cell
   End If

End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39927895
Sub testcomment()
    [Q2].AddComment
    [Q2].Comment.Text "This is the comment" & Format([M2])
    [Q2].Value = "Check comment"
End Sub

Open in new window

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:zerog
ID: 39927946
Thank you for your response. Is there a way I can add that to work in the advanced piece of code I posted?
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39927953
Between lines 16 and 17 add

Cell.Value = "Check comment"
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39929579
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question