Undo Removal of Trailing Zeros

NetFlash

New Member
Joined
Jul 26, 2011
Messages
14
Hello Guys,

I've stumbled upon a "feature" in Excel i can't exclude.
1000 0.188
2000 -0.401
3000
0.000
4000
-1.102

When you set the display format for numeric 2digits, Excel changes the Display not the underlying Value
Display Value
0.19 0.19
-0.40 -0.4
0.00 0

-1.10 -1.1

How do i STOP excel from removing trailing zeros.
I tried Tools>Options>Calculations>Precision as Displayed.
This works well with numbers not ending on 0. But numbers ending with 0 still get truncated.

I do Not want to convert the values to text. They have to stay numeric as they have to be rounded off automatically, and used to generate code.
so lets say if i fill in 0.40267 -> rouds off to 0.40
And what i get now is 0.4 which is unusable for the generated code.

Any ideas??
 
Hmm Please check.

Can i write out this
Code:
colC = Format(Abs(cellData.Offset(, 1)), "0.0") & IIf(cellData.Offset(, 1) < 0, "-", "")
To this:
Code:
        colC = Format(Abs(cellData.Offset(, 1)), "0.00")
        If (cellData.Offset(, 1) < 0) Then
            colC = Abs(cellData.Offset(, 1)) & "-"
        Else
            colC = cellData.Offset(, 1)
        End If
I've tested it and it doesn't work. i does not format to 0.00.
Please help me find the loose screws.... ;)
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hmm Please check.

Can i write out this
Code:
colC = Format(Abs(cellData.Offset(, 1)), "0.0") & IIf(cellData.Offset(, 1) < 0, "-", "")
To this:
Code:
        colC = Format(Abs(cellData.Offset(, 1)), "0.00")
        If (cellData.Offset(, 1) < 0) Then
            colC = Abs(cellData.Offset(, 1)) & "-"
        Else
            colC = cellData.Offset(, 1)
        End If
I've tested it and it doesn't work. i does not format to 0.00.
Please help me find the loose screws.... ;)

Hi

If you want like in the second snippet, try:

Code:
        colC = Format(Abs(cellData.Offset(, 1)), "0.00")
        If (cellData.Offset(, 1) < 0) Then colC = colC & "-"
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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