Solved

Populate cell and cell comment

Posted on 2014-03-13
6
351 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 45

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 45

Accepted Solution

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

Cell.Value = "Check comment"
0
 
LVL 45

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now