convert string with a decimal to a string with a exponential

HankJ

Board Regular
Joined
Mar 5, 2016
Messages
89
Hello

I would like to convert a string with a decimal value >100.00000, which are in units of µM to a string with an exponential value, > 1.00E-04.

For example:

[TABLE="width: 84"]
<colgroup><col></colgroup><tbody>[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
[TR]
[TD]>100.000000[/TD]
[/TR]
</tbody>[/TABLE]

to

[TABLE="width: 90"]
<colgroup><col></colgroup><tbody>[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04
[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04[/TD]
[/TR]
[TR]
[TD]> 1.00E-04
[/TD]
[/TR]
</tbody>[/TABLE]

the bit of code I am using changes everything to >0.0001!

Code:
If Left(Selection.Value, 1) = ">" Then
Selection.Offset(0, -1).FormulaR1C1 = _
"=MID(RC[1],2,SEARCH(CHAR(127),SUBSTITUTE(RC16,""."",CHAR(127),1))-2)/1000000"
Selection.Offset(0, 2).Value = Selection.Offset(0, -1).Value
Selection.Offset(0, 2).NumberFormat = "0.00E+00"
ConcVal = Selection.Offset(0, 2).Value
Selection.Offset(0, 2).Value = "> " & ConcVal
Selection.Offset(0, -1).Value = ""
Selection.Value = ""

This was an attempt to force the value to be a string but does not quite work.

I would be grateful for suggestions.

Many thanks

Hankj
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try
Code:
ConcVal = Format(Selection.Offset(0, 2).Value, "0.00E+00")
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top