importing large numbers to vb results in the numbers being formatted to scientific

M

molly

HI,

I am trying to stop large numbers such as
0.0977376573888888 being read into vb as

9.77376573888888E-02 when I import using the following

strRate=xlApp.Worksheets(intSheetNo).Range(strRateCol & intI).Value

I wish to read that number and format it to 4 decimal places
as follows

..0977.
However, it is already read in in scientific notation so I cannot
format it then. Does anyone know how to solve this?

Thanks

Molly
 
B

Bernie Deitrick

Molly,

Simply format it in the same step as when you read it:

Dim strRate As String
strRate = Format(xlApp.Worksheets(intSheetNo) _
..Range(strRateCol & intI).Value, "0.0000")
MsgBox strRate

This will give 0.0977, which is what I assumed you wanted when you
meant 4 decimal places.

If you really want 0977. then you will need to use:

strRate = Format(10000 * Worksheets(1) _
..Range("A" & 1).Value, "0000.")

HTH,
Bernie
MS Excel MVP
 
M

molly

thanks for you help... I was all set to write a ridulous function to
find E etc..
 

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