Format DecimalPlaces in VB

S

Stephen.

Hi all.

I run the following function in access (quite time
consuming)
ResultCalcfield= ExcelObject.WorksheetFunction.NormSInv(1 -
datafeild1/ datafeild2) + 1.5
but need the result to be formatted to 1st decimal place,
I have searched the help, but not really found anything
that useful.

Could anyone please assist?
 
J

JimB

Stephen,

After the function, you can either select the column or a
range of cells and use the NumberFormat command. It took
me awhile to find this myself. The intCT2 in the example
is the record count and formats only the cells I want.

ExcelObject.Worksheets("yoursheet").Range("i8:i" & intCT2
& 9).NumberFormat = "#,##0.0"

Or...the whole column.....

ExcelObject.Worksheets("yoursheet").Columns
("d").NumberFormat = "#,##0.0"
 
T

Tim Ferguson

but need the result to be formatted to 1st decimal place,

.... or do it the oldfashioned way:

ResultCalField = Int(ResultCalcField * 10 + 0.5) * 0.10

HTH


Tim F
 

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