Excel changes the values of my numbers

L

Linda

I have coded a simple user form in Excel that calculates a balance an
assigns the proper values to cells in a worksheet. What I don'
understand is that when I enter a number into the user form, the valu
of that number changes once it gets assigned to the cell in th
worksheet. For example, if I enter the number 542.73 ,the user for
assigns the number to the proper cell in the worksheet but it shows u
as 542.72998046875. It should show up as 542.73 because that's what
entered. I am calculating a running balance so my calculations aren'
coming out right. Sometimes they are off by a penny and I can't hav
that happen. Every number I enter into the form changes once it get
assign to the cell in the worksheet. I've been trying to figure ou
how to fix this but I haven't come up with anything. Does anyone kno
why this happens and how to fix it?

lind
 
D

David

Linda

You don't say how the value gets put into the cell, but it must be being
transformed in some way.

However, if you use the function ROUND(yourValue, 2) you should find that it
will be correctly entered to 2 dp.

David
 
L

Linda

Hello David,

The number gets assigned to the cell once I click a calculate button o
my user form that I coded in the vba editor. I have about si
different input areas on the user form and each of them gets assigne
to different cells on the worksheet once I hit the calculate button.
Three of them are numbers and they all get transformed (as you said
somehow when they are assigned to the cells. I'm worried about usin
the round function because some of them would actually be rounded wron
and I end up being a penny off. I think it would eventually be of
more and more the further I did the calculations. I just don't kno
why the numbers are changing in the first place. Here is an example o
a sample calculation that I just tried.

There is an original balance of 500.00 on the worksheet.
I input a 450.62 payment in the user form.
Once I hit the calculat button on the user form, the 450.62 is assigne
to the proper cell and the balance is calculated and assigned to th
proper cell.
The balance that was assigned to the cell is 49.3800010681152.
It should be 49.38.

I would use the round function but as I said before, some of them ar
off too much and actually round wrong.

I don't know if you need any more info. than this but thanks for you
help.

lind
 

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