ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sub to write formula results into comments (https://www.excelbanter.com/excel-programming/395319-sub-write-formula-results-into-comments.html)

Max

Sub to write formula results into comments
 
I'd select a formula range, eg select B2:C10, and would like to run a sub to
write all formula results into each cell's comment. Thanks.

Rgds
Max



joel

Sub to write formula results into comments
 
Sub FormulaToComment()

'

'
For Each cell In Selection
If Len(cell.Formula) 0 Then
If cell.Comment Is Nothing Then
cell.AddComment
End If
cell.Comment.Text Text:=cell.Formula
End If
Next cell
End Sub

"Max" wrote:

I'd select a formula range, eg select B2:C10, and would like to run a sub to
write all formula results into each cell's comment. Thanks.

Rgds
Max




Max

Sub to write formula results into comments
 
Thanks, Joel. Tried your sub, but it doesn't write the required formula
*results* into the comments. It writes the formulas. Could your sub be
amended to yield the necessary?

Rgds
Max



JLGWhiz

Sub to write formula results into comments
 
Change this line:

cell.Comment.Text Text:=cell.Formula

To:

cell.Comment.Text Text:=cell.Value
"Max" wrote:

Thanks, Joel. Tried your sub, but it doesn't write the required formula
*results* into the comments. It writes the formulas. Could your sub be
amended to yield the necessary?

Rgds
Max




Max

Sub to write formula results into comments
 
Thanks, JLGWhiz !
That change did it.

Rgds
Max




All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com