Sub to write formula results into comments

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
 
G

Guest

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
 
M

Max

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
 
G

Guest

Change this line:

cell.Comment.Text Text:=cell.Formula

To:

cell.Comment.Text Text:=cell.Value
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top