wsteph
asked on
Changing the format of numbers using the Excel object in VB
How can I change the decimal point of numbers in an Excel spreadsheet through VB? The code I'm using is this:
.Range("B6:I16").Value.Num berFormat = "#0.00"
which only changes the display of numbers but not the value, which is still in it's original form.
.Range("B6:I16").Value.Num
which only changes the display of numbers but not the value, which is still in it's original form.
Hi WSteph,
If you need to round the numbers as displayed by your previous command, use this little code part (preceded by .)
For Each Cell In .Range("B6:I16")
Cell.Value = Application.WorksheetFunct ion.Round( Cell, 2)
Next Cell
The 'Application' is the running excel instance in this example, replace it by what you have as an Excel application if you're operating from outside.
Hope this helps
Calacuccia
If you need to round the numbers as displayed by your previous command, use this little code part (preceded by .)
For Each Cell In .Range("B6:I16")
Cell.Value = Application.WorksheetFunct
Next Cell
The 'Application' is the running excel instance in this example, replace it by what you have as an Excel application if you're operating from outside.
Hope this helps
Calacuccia
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
..Range("B6:I16").NumberFo