Paste into a Comment

jpstory

Board Regular
Joined
Dec 17, 2010
Messages
118
I am trying to record a macro that copies numbers from one cell and paste into a comment, when recording, I copied the numbers from the formula bar and then pasted into the comment. However, every time when I run the macro, it repeatedly pastes the exactly same number I copied during recording the macro into the comment.

Any help will be appreciated , thank!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Not seeing your code, the crux is, you'd need to have the comment's text be that of the cell address' value. That is different than what VBA sees as a static act you are doing, which is copying a value from the formula bar. Refer to the value belonging to a cell, rather than the specific value itself. Example, comment.text = Range("A1").value [actually that is not real code butan attempt to relate the concept of what I am speaking about].
 
Upvote 0
Thanks guys, greatly appreciate your help here.

Sorry for the confusion, I am trying to copy the numbers from any active cell and then paste the numbers into the comment on adjacent cell. Here is what I wrote:

Sub Copy_Paste_Comment()
ActiveCell.Select
Selection.Copy
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Text:=
ActiveSheet.Paste
End Sub

The line in bold red is where I got stock. Any thoughts?
 
Upvote 0
Can you define what "adjacent cell" means exactly for "any active cell". Example, if you have cell T743 selected, you would want the comment in cell U743 to contain the numbers or text or whatever that is in cell T743? And what if cell U743 does nor contain a comment? and what if it does, do you want T743's value to be added to, or be a replacement for, the current comment text?
 
Upvote 0
For example, the numbers will be in cell A1, and I will first create a comment in cell B1 which is empty, and then copy the numbers in cell A1 and paste into the comment in B1
 
Upvote 0
Try

Code:
Sub Copy_Paste_Comment()
ActiveCell.Offset(0, 1).AddComment
ActiveCell.Offset(0, 1).Comment.Visible = False
ActiveCell.Offset(0, 1).Comment.Text Text:=ActiveCell.Text
End Sub
 
Upvote 0
Great.

you could use a With ...

Code:
With ActiveCell.Offset(0, 1)
.AddComment
.Comment.Visible = True
.Comment.Text Text:=ActiveCell.Text
End With
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,314
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top