Is there a way to extract numbers from comments for use in a formu

G

Guest

I have comments that have numbers in them that I would like to be able to
extract from the comments and use a mathematical formula (simple
multiplication) to find the product of the numbers.

Thanks for any help that you can provide!
 
G

Guest

Let's say we are talking about a single cell that contains a comment and the
comment contains a single number and nothing else. Select the cell and run:

Sub get_comment_number()
Dim s As String, n As Long
With Selection
.Comment.Visible = True
s = .Comment.Text
n = s * 1#
.Value = n
End With
End Sub

The macro will set the value of the cell equal to the number in the comment.


Remember:
1.the original contents of the cell will be over-written
2.will work only on a single cell
3.the comment must be a single number
 

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