Sub to write formula results into comments

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

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
 
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
 
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
 
Change this line:

cell.Comment.Text Text:=cell.Formula

To:

cell.Comment.Text Text:=cell.Value
 
Back
Top