ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem displaying a calculation result in a user form (https://www.excelbanter.com/excel-programming/346541-problem-displaying-calculation-result-user-form.html)

Andyroo

Problem displaying a calculation result in a user form
 
I have developed a fairly simple game in Excel 2002. One feature is a
statistics box that shows the player the numbers of wins and losses and the
percentage of wins.

I have set this up using 3 text boxes each with a ControlSource link to the
sheet and cell that contains the relevant data. It works fine for the
numbers of wins and the number of losses but I keep finding that the 3rd item
hits a bug whereby the cell containing the calculation of the win percentage
somehow loses the calculation and it is replaced by an integer.

Can anyone help? Maybe there is an easier/more secure way to calculate the
win percentage from within the user form??

Bob Phillips[_6_]

Problem displaying a calculation result in a user form
 
Show the code?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"AndyRoo" wrote in message
...
I have developed a fairly simple game in Excel 2002. One feature is a
statistics box that shows the player the numbers of wins and losses and

the
percentage of wins.

I have set this up using 3 text boxes each with a ControlSource link to

the
sheet and cell that contains the relevant data. It works fine for the
numbers of wins and the number of losses but I keep finding that the 3rd

item
hits a bug whereby the cell containing the calculation of the win

percentage
somehow loses the calculation and it is replaced by an integer.

Can anyone help? Maybe there is an easier/more secure way to calculate

the
win percentage from within the user form??




Andyroo

Problem displaying a calculation result in a user form
 
Not sure what you mean by 'show the code'. If you mean what I have written
in the Macro, it is shown below.

In the sheet the statistics are in ('stats') I have a calculation for
percentage wins as follows in cell B9:

=IF(ISERROR(100*B5/B7),0,(100*B5/B7)). In Cell B11 I have a formula to
round that to 1 decimal, =ROUND(B9,1).

In the properties box for my userform I have tried linking to both cells B9
and B11 using the ControlSource property. I have found that when I enter
Sheets!B9 (or B11 for that matter) in the section for ControlSource then the
user form picks up the figure I want it to, at first.

However after a couple of uses of the game the macro is in, I find the
figure for percentage wins no longer updates. When I investigate I find that
the formula in the calculation cells has disappeared and in its place is an
integer (not a random one, it is the calculated percentage of wins the last
time the formula worked).

I have tried stepping through the code in debugging mode but nothing goes
wrong when I step through the code, so I am baffled.

Hope that is clear, any help gratefully received.

"Bob Phillips" wrote:

Show the code?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"AndyRoo" wrote in message
...
I have developed a fairly simple game in Excel 2002. One feature is a
statistics box that shows the player the numbers of wins and losses and

the
percentage of wins.

I have set this up using 3 text boxes each with a ControlSource link to

the
sheet and cell that contains the relevant data. It works fine for the
numbers of wins and the number of losses but I keep finding that the 3rd

item
hits a bug whereby the cell containing the calculation of the win

percentage
somehow loses the calculation and it is replaced by an integer.

Can anyone help? Maybe there is an easier/more secure way to calculate

the
win percentage from within the user form??






All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com