Converting DataLabels to Numbers

  • Thread starter Thread starter Dan Gesshel
  • Start date Start date
D

Dan Gesshel

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
 
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
 
Back
Top