close

How do I format a UserForm TextBox to round decimal numbers to the
nearest whole number.
ie
1.0, 1.1, 1.2, 1.3, 1.4 should all round down to 1.
1.5, 1.6, 1.7, 1.8, 1.9 should all round up to 2.
I can get it to display the Interger but this always rounds down.--
grahammal
------------------------------------------------------------------------
grahammal's Profile: www.excelforum.com/member.php...oamp;userid=20336
View this thread: www.excelforum.com/showthread...hreadid=532225dim myVal as double
myval = 1.4
me.textbox1.value = round(myval,0)

if you're using xl97:
me.textbox1.value = application.round(myval,0)grahammal wrote:
gt;
gt; How do I format a UserForm TextBox to round decimal numbers to the
gt; nearest whole number.
gt; ie
gt; 1.0, 1.1, 1.2, 1.3, 1.4 should all round down to 1.
gt; 1.5, 1.6, 1.7, 1.8, 1.9 should all round up to 2.
gt; I can get it to display the Interger but this always rounds down.
gt;
gt; --
gt; grahammal
gt; ------------------------------------------------------------------------
gt; grahammal's Profile: www.excelforum.com/member.php...oamp;userid=20336
gt; View this thread: www.excelforum.com/showthread...hreadid=532225

--

Dave Peterson


Your resolve is fine thankyou but I should have made my query a little
clearer.
The decimal to resolve is'nt just between 1 amp; 2 it could be anything.
ie 2.7, 7.1, 11.6, 5.3 etc.
Can you work your magic once more.--
grahammal
------------------------------------------------------------------------
grahammal's Profile: www.excelforum.com/member.php...oamp;userid=20336
View this thread: www.excelforum.com/showthread...hreadid=532225The part that does the work is this line:

me.textbox1.value = round(myval,0)

I guess the next question is where do you get the value you want to round?

I just created myVal to have some test data. You'd use whatever variable holds
that number.

grahammal wrote:
gt;
gt; Your resolve is fine thankyou but I should have made my query a little
gt; clearer.
gt; The decimal to resolve is'nt just between 1 amp; 2 it could be anything.
gt; ie 2.7, 7.1, 11.6, 5.3 etc.
gt; Can you work your magic once more.
gt;
gt; --
gt; grahammal
gt; ------------------------------------------------------------------------
gt; grahammal's Profile: www.excelforum.com/member.php...oamp;userid=20336
gt; View this thread: www.excelforum.com/showthread...hreadid=532225

--

Dave Peterson

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

    software

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