Solved

Populate cell and cell comment

Posted on 2014-03-13
6
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 48

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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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 48

Accepted Solution

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

Cell.Value = "Check comment"
0
 
LVL 48

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

691 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