ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Converting DataLabels to Numbers (https://www.excelbanter.com/excel-programming/273267-converting-datalabels-numbers.html)

Dan Gesshel

Converting DataLabels to Numbers
 
Hello.

I am trying to extract numbers from a Datalabel. Unfortunately, besides the
fact I am having trouble using the CInt or CDbl codes to do this, the label
contains both text and numbers. (Perhaps a Right code would help?)

Anyway, for example, the label will be "KHJ-LMNO 15%." I need to convert
this 15% to a numeric value to use in a loop in another procedure. The other
problem is sometimes it could be a single digit value, such as 3% or
possibly a three digit value, such as 100%. The extraction and conversion
would have to work for all scenarios.

Any help would be grealy appreciated.

Thanks.

Dan



Myrna Larson[_2_]

Converting DataLabels to Numbers
 
If it is always preceded by a space and ends with a % sign:

i = instr(ALabel, " ") + 1
j = instr(i, ALabel, "%")
x = CDbl(Mid$(ALabel,i, j - i))/100


On Fri, 01 Aug 2003 02:54:34 GMT, "Dan Gesshel" wrote:

Hello.

I am trying to extract numbers from a Datalabel. Unfortunately, besides the
fact I am having trouble using the CInt or CDbl codes to do this, the label
contains both text and numbers. (Perhaps a Right code would help?)

Anyway, for example, the label will be "KHJ-LMNO 15%." I need to convert
this 15% to a numeric value to use in a loop in another procedure. The other
problem is sometimes it could be a single digit value, such as 3% or
possibly a three digit value, such as 100%. The extraction and conversion
would have to work for all scenarios.

Any help would be grealy appreciated.

Thanks.

Dan




All times are GMT +1. The time now is 04:50 PM.

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