Sunjinsak
Board Regular
- Joined
- Jul 13, 2011
- Messages
- 151
- Office Version
- 365
- 2019
- 2016
- 2013
- Platform
- Windows
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I have a problem with the way results of a calculation are displayed on a user form I’ve made in VBA for Excel 2003.<o></o>
<o></o>
I have two calculations which work out two results – resultA and resultB.<o></o>
<o></o>
There are no issues with the calculations themselves as they are working perfectly and calculating the correct result every time.<o></o>
<o></o>
The problem comes when I try to display those results on the user form. They have to be displayed in a very specific way when displayed to the end user (the reason for this is too long to go into here but suffice to say there is no way around it unfortunately).<o></o>
<o></o>
resultA always needs to be rounded up to the nearest integer. For example a result of 177.6 should be displayed as 178 - as would a result of 177.1.<o></o>
<o></o>
resultB should not be rounded at all (in either direction) but displayed to one decimal place. For example a result of 62.16 should be displayed as 62.1. A result of 59.52 should be displayed as 59.5 etc<o></o>
<o></o>
I’ve written the following code to display the results:<o></o>
<o></o>
<o></o>
<o></o>
<o></o>
Unfortunately, using the figures given earlier as examples (177.6 for resultA and 62.16 for resultB), the above code displays the results as 180 and 63. They should however be displayed as 178 and 62.1 respectively.<o></o>
<o></o>
Can anyone point out where I’m going wrong or otherwise help me achieve what I want to do?<o></o>
<o></o>
Thanks.
<o></o>
I have a problem with the way results of a calculation are displayed on a user form I’ve made in VBA for Excel 2003.<o></o>
<o></o>
I have two calculations which work out two results – resultA and resultB.<o></o>
<o></o>
There are no issues with the calculations themselves as they are working perfectly and calculating the correct result every time.<o></o>
<o></o>
The problem comes when I try to display those results on the user form. They have to be displayed in a very specific way when displayed to the end user (the reason for this is too long to go into here but suffice to say there is no way around it unfortunately).<o></o>
<o></o>
resultA always needs to be rounded up to the nearest integer. For example a result of 177.6 should be displayed as 178 - as would a result of 177.1.<o></o>
<o></o>
resultB should not be rounded at all (in either direction) but displayed to one decimal place. For example a result of 62.16 should be displayed as 62.1. A result of 59.52 should be displayed as 59.5 etc<o></o>
<o></o>
I’ve written the following code to display the results:<o></o>
<o></o>
Code:
LabelA.Caption = Application.RoundUp(resultA, 0)
Code:
LabelB.Caption = Format(resultB, ".#")
<o></o>
Unfortunately, using the figures given earlier as examples (177.6 for resultA and 62.16 for resultB), the above code displays the results as 180 and 63. They should however be displayed as 178 and 62.1 respectively.<o></o>
<o></o>
Can anyone point out where I’m going wrong or otherwise help me achieve what I want to do?<o></o>
<o></o>
Thanks.