Copy cell value to other cell Comment

theojanissen

New Member
Joined
Dec 16, 2014
Messages
6
Hi all,

Any help on this would make my day :)

I need a macro that places the result of the formula of e.g. cell B6 to the Comment box of e.g. cell D6. (Old values within the Comment box have to be removed first)

Thanks,

Theo
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi,

Try this code. If there is no formula in cell B6 then code will add empty comment to cell D6.

Code:
Sub FormulaToCellComment()


Dim Formula_ As String


Formula_ = Sheets("Sheet1").Range("b6").Formula


On Error Resume Next
Sheets("Sheet1").Range("d6").Comment.Delete
On Error GoTo 0


Sheets("Sheet1").Range("d6").AddComment Formula_


End Sub

Hope that it'll work for you.

Regards,
 
Upvote 0
Hi,

Try this code. If there is no formula in cell B6 then code will add empty comment to cell D6.

Code:
Sub FormulaToCellComment()


Dim Formula_ As String


Formula_ = Sheets("Sheet1").Range("b6").Formula


On Error Resume Next
Sheets("Sheet1").Range("d6").Comment.Delete
On Error GoTo 0


Sheets("Sheet1").Range("d6").AddComment Formula_


End Sub

Hope that it'll work for you.

Regards,

Thanks. :)

In the mean time I found a waythat works also:

Sub CellValueToCellCcontent()
Range("B6").Select
y = ActiveCell.Value
Range("D6").Select
ActiveCell.Comment.Text y
End Sub
 
Upvote 0
I tested your code and it didn't work for me. It stopped at the last row. If I update last row in your code like this, it works:

Code:
Sub CellValueToCellCcontent()


Dim Y


Range("B6").Select
Y = ActiveCell.Value
Range("D6").Select
'ActiveCell.Comment.Text Y


ActiveCell.AddComment CStr(Y)


End Sub

However it will work only if there is no comment in cell D6. I'd suggest to use my code. I updated .formula to .value:

Code:
Sub FormulaToCellComment()


Dim Formula_ As String


Formula_ = Sheets("Sheet1").Range("b6").Value 'I updated this row


On Error Resume Next
Sheets("Sheet1").Range("d6").Comment.Delete
On Error GoTo 0


Sheets("Sheet1").Range("d6").AddComment Formula_


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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