ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Is there a way to extract numbers from comments for use in a formu (https://www.excelbanter.com/excel-discussion-misc-queries/118312-there-way-extract-numbers-comments-use-formu.html)

cadscout

Is there a way to extract numbers from comments for use in a formu
 
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!

Gary''s Student

Is there a way to extract numbers from comments for use in a formu
 
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
--
Gary's Student


"cadscout" wrote:

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!



All times are GMT +1. The time now is 04:44 AM.

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