Forum

Notifications
Clear all

Add comment to cell from another cell contents.

9 Posts
2 Users
0 Reactions
495 Views
(@andywhite)
Posts: 12
Eminent Member
Topic starter
 

Please Note :  I have also posted this question on LinkedIn (Excel Data Analyst Group)

Any help solving this issue would be greatly appreciated...
Table Name = ORDER1
I would like to add the cell contents from column 'Comments' into a comment (Red Triangle that appears in top right of cell when hovered over) in Column 'Operation' for each row in the table.

Ideally the comment box would auto resize dependent on comment length.

Any Ideas ???

Have a good weekend everyone.

Andy

 
Posted : 22/01/2022 10:41 am
(@debaser)
Posts: 836
Member Moderator
 

Essentially the code would be something like:

sub AddCommentsToOperations()

application.screenupdating = false

dim myTable as listobject

set mytable = activesheet.listobjects("ORDER1")

dim rw as long

for rw = 1 to mytable.listrows.count

dim cell as range

set cell = mytable.listcolumns("Operation").databodyrange.cells(rw)

if not cell.comment is nothing then cell.comment.delete

cell.addcomment mytable.listcolumns("Comments").databodyrange.cells(rw).value

next rw

end sub

 
Posted : 22/01/2022 11:43 am
(@andywhite)
Posts: 12
Eminent Member
Topic starter
 

Thanks Velouria,

 

I will give it a try.

 

Andy

 
Posted : 22/01/2022 2:19 pm
(@andywhite)
Posts: 12
Eminent Member
Topic starter
 

Hi Velouria,

Hope you’re enjoying the weekend and many thanks for you’re help.

 

im just going to test your code to see if it works and solves my problem.

what type of code selection do i need to make when entering the code.

 

Worksheet & deceleration ****

Is it tableupdate as my data is in a table not a pivot table 

best Regards

 

andy

 
Posted : 23/01/2022 4:29 pm
(@debaser)
Posts: 836
Member Moderator
 

It depends - what do you want to trigger the code?

 
Posted : 25/01/2022 4:47 am
(@andywhite)
Posts: 12
Eminent Member
Topic starter
 

Hi Velouria,

I hope you are well,

You're code below is working brilliantly.

sub AddCommentsToOperations()

application.screenupdating = false

dim myTable as listobject

set mytable = activesheet.listobjects("ORDER1")

dim rw as long

for rw = 1 to mytable.listrows.count

dim cell as range

set cell = mytable.listcolumns("Operation").databodyrange.cells(rw)

if not cell.comment is nothing then cell.comment.delete

cell.addcomment mytable.listcolumns("Comments").databodyrange.cells(rw).value

next rw

end sub

 

Quick question

How would I amend the code to do the same function with the comments on multiple tables in the same worksheet.

All tables have the same column names etc..  it's just the table names that are different - example table names   ORDER1_2,  ORDER1_3

 

Best Regards

 

Andy

 
Posted : 31/01/2022 3:40 pm
(@debaser)
Posts: 836
Member Moderator
 

Do you want it to do every table on the sheet? If so, something like:

 

sub AddCommentsToOperations()

application.screenupdating = false

dim myTable as listobject

for each myTable in activesheet.listobjects

dim rw as long

for rw = 1 to mytable.listrows.count

dim cell as range

set cell = mytable.listcolumns("Operation").databodyrange.cells(rw)

if not cell.comment is nothing then cell.comment.delete

cell.addcomment mytable.listcolumns("Comments").databodyrange.cells(rw).value

next rw

next mytable

end sub

 
Posted : 01/02/2022 6:14 am
(@andywhite)
Posts: 12
Eminent Member
Topic starter
 

Thanks so much Velouria,

Exactly what I was looking for.

 

Thanks again and have a great week.

 

Andy

 
Posted : 01/02/2022 7:01 am
(@debaser)
Posts: 836
Member Moderator
 

You're welcome! 🙂

 
Posted : 01/02/2022 7:32 am
Share: