close

Hi All,

I have a user form and on that form is a text box. Data from a cell on
the worksheet is read into that text box and the user can observe it.

A simple calculation is done on the cell before it is read into the
text box. This produces a number with a large number of decimal places.
Even though I set the number of decimal places of that cell to 2 (via
right clicking on the cell and selecting quot;Format Cells...quot;) the number
read into the text box still displays all the decimal places.

Could anyone tell me how I can set the number of decimal places of the
text box itself?

Best Regards,

Aaron--
Aaron1978
------------------------------------------------------------------------
Aaron1978's Profile: www.excelforum.com/member.php...oamp;userid=31201
View this thread: www.excelforum.com/showthread...hreadid=519786
Try adding this to your formula:

=ROUND((your formula),2)

It will round your result to 2 decimal places.
quot;Aaron1978quot; wrote:

gt;
gt; Hi All,
gt;
gt; I have a user form and on that form is a text box. Data from a cell on
gt; the worksheet is read into that text box and the user can observe it.
gt;
gt; A simple calculation is done on the cell before it is read into the
gt; text box. This produces a number with a large number of decimal places.
gt; Even though I set the number of decimal places of that cell to 2 (via
gt; right clicking on the cell and selecting quot;Format Cells...quot;) the number
gt; read into the text box still displays all the decimal places.
gt;
gt; Could anyone tell me how I can set the number of decimal places of the
gt; text box itself?
gt;
gt; Best Regards,
gt;
gt; Aaron
gt;
gt;
gt; --
gt; Aaron1978
gt; ------------------------------------------------------------------------
gt; Aaron1978's Profile: www.excelforum.com/member.php...oamp;userid=31201
gt; View this thread: www.excelforum.com/showthread...hreadid=519786
gt;
gt;


Thanks for your reply, but the calculation is done in VBA not in the
cell that the data is read from. Is there a way of rounding numbers in
VBA, I tried but can't seem to find a way.

Best Regards,

Aaron--
Aaron1978
------------------------------------------------------------------------
Aaron1978's Profile: www.excelforum.com/member.php...oamp;userid=31201
View this thread: www.excelforum.com/showthread...hreadid=519786Excel 2000 and later has a VBA Round function. It does ASTM rounding (rounds
to nearest rounded value, with ties [exactly 5] rounding up or down to make
an even number).

In earlier versions (or to always round 5 up) you can call the worksheet
Round function from VBA by either
Application.Round()
or
WorksheetFunction.Round()
The former former will work in all versions of Excel that support VBA. I
believe that the latter was introduced in Excel 97, but has the advantage of
prompting you with possible worksheet functions that can be called in this
way.

Jerry

quot;Aaron1978quot; wrote:

gt;
gt; Thanks for your reply, but the calculation is done in VBA not in the
gt; cell that the data is read from. Is there a way of rounding numbers in
gt; VBA, I tried but can't seem to find a way.
gt;
gt; Best Regards,
gt;
gt; Aaron
gt;
gt;
gt; --
gt; Aaron1978
gt; ------------------------------------------------------------------------
gt; Aaron1978's Profile: www.excelforum.com/member.php...oamp;userid=31201
gt; View this thread: www.excelforum.com/showthread...hreadid=519786
gt;
gt;

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()