Avatar of Kevin Buckland
Kevin Buckland
Flag for United States of America asked on

Copy cell contents for multiple columns and put into a comment for a cell in another column

I have a daily routine that involves downloading a list that I need the cell contents of several columns to be populated into a comment for the cell in column A for the same row -- but also have the heading (row 1) for each column to preface the data populated in the column.  

For the attached I'd like the following column values populated into the comments, in this order:
CUSIP (Col I)
Sec Short Name (Col L)
Trade Date (Col J)
Broker ID (Col K)
Trader Login (Col M)
Security Type (Col N)

So for A3, I'd like the comment to be populated with the following:
CUSIP: 36251MAA9
Sec Short Name: GMALT 2016-3 A1
Trade Date: 3/23/2017
Broker ID: JOURNAL
Trader Login: KBBUCKLAND
Security Type: ABS Auto

Repeat all the way down the list.

I'd also like it to have the ability to not breakdown if a cell value is empty.  

Thank you

Please note this is an expanded request to the thread answered below:

https://www.experts-exchange.com/questions/29011301/Copy-cell-contents-for-two-columns-and-put-into-a-comment-for-a-cell-in-another-column.html?anchor=a42062290¬ificationFollowed=186303770&anchorAnswerId=42062290#a42062290
TBLTall-Worksheet1-expanded.xls
Microsoft ExcelVBAMicrosoft Office

Avatar of undefined
Last Comment
Shums Faruk

8/22/2022 - Mon
SOLUTION
Shums Faruk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Shums Faruk

Please find attached for your reference:
TBLTall-Worksheet1_v2.xlsm
Kevin Buckland

ASKER
This worked good all in all but a couple values were populating from a wrong column offset.  

I'd ideally like each one to start on a new line in the comment.  Is there a way to put a hard return after each value ? For instance the "Sec" (beginning of "Sec Short Name") displays after the cusip populated. I'd ideally like each one to start on a new line just for readability.  

This is the change I made for the column offset:
Sub TBLTcomments()
'
' TBLTcomments Macro
' Takes various info including broker and CUSIP and puts into cell comment of the security description.
' Requires SHEET1 EXPANDED COLUMNS instead of the old SHEET 1 as the starting point.
'
'
Dim Ws As Worksheet
Dim LR As Long
Dim Rng As Range
Set Ws = ActiveSheet
LR = Ws.Range("A" & Rows.Count).End(xlUp).Row
Set Rng = Ws.Range("A3:A" & LR)
For Each Cell In Rng.Cells
    Dim I As Range
    Dim L As Range
    Dim J As Range
    Dim K As Range
    Dim M As Range
    Dim N As Range
    Set I = Cell.Offset(0, 8)
    Set L = Cell.Offset(0, 11)
    Set J = Cell.Offset(0, 9)
    Set K = Cell.Offset(0, 10)
    Set M = Cell.Offset(0, 12)
    Set N = Cell.Offset(0, 13)
    With Cell
            .ClearComments
            .AddComment "CUSIP: " & I.Value & " Sec Short Name: " & L.Value & " Trade Date: " & J.Value & " Broker ID: " & K.Value & " Trader Login: " & M.Value & " Security Type: " & N.Value
    End With
Next
End Sub

Open in new window

Kevin Buckland

ASKER
Also is there any way to expand the size of the comment so when I just hover over it I can see it all? Currently I have to expand the size of each comment to be able to see all the data in the comment.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Shums Faruk

Yes Kevin, I did noticed, give me few mins, I will change it.
ASKER CERTIFIED SOLUTION
Shums Faruk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Kevin Buckland

ASKER
Works like a charm!  Thanks!
Shums Faruk

You're Welcome Kevin! Glad I was able to help again :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.