Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA and displayed values different 1

Status
Not open for further replies.

randy700

Programmer
Sep 25, 2003
2,384
US
I'm trying to upload data from an Excel 2007 spreadsheet to the mainframe. To satisfy my clients needs, I've created a macro that processed the data. I'm working with as many as 5 decimal places, with only 2 decimals displayed in the spreadsheet. The client wants the DISPLAYED value uploaded, with the decimal point removed. This data's intended use will be for a COBOL program.

Here's my problem.
Actual value: 75.09625 (cell C54)
Display: 75.10
Desired output: 7510
VBA Formula: round(C54,2)*100 = 7510
....this is GOOD.

Actual value: 191.485 (cell C55)
Display: 191.49
Desired output: 19149
VBA Formula: round(C55,2)*100 = 19148

Using the same formula in the Excel grid yields the desired output (19149).
This only happens when the actual value has 3 decimal places, ending in a 5.

Does anyone have a clue how to get the desired output in VBA code?


Randy
 
What about this ?
VBA formula: Replace(C55.Text, ".", "")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



or
Code:
    x = 191.489
    y = Int((x + 0.005) * 100)

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I used Skip's suggestion (slightly modified).
Code:
=Round(C55 + 0.000001, 2) * 100

Works perfectly -- Thanks, Skip

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top