Textbox - Easy One (Hopefully)

RWinfield

New Member
Joined
Feb 16, 2002
Messages
33
I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

TextBox3.Value = Range("d4")

Thanks for any help,

Rick
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
On 2002-02-26 12:38, RWinfield wrote:
I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

TextBox3.Value = Range("d4")

Thanks for any help,

Rick

Try this:

TextBox3.Value = Range("d4").Text

HTH,

Russell
 
Upvote 0
On 2002-02-26 12:38, RWinfield wrote:
I have a userform in which one of the text boxes displays information from a particular cell on the worksheet. I have formatted the cell in question to only display integer, ie no decimal places, but when the value is imported into the textbox, the textbox displays 8 decimal places. How do I display only the characters to the left of the decimal point in the textbox? The code is below, but is pretty simple actually.

TextBox3.Value = Range("d4")

Thanks for any help,

Rick

TextBox3.Value = Int(Range("D4").value)
 
Upvote 0
My last post didn't take into account the fact that if you have set the cell format to not show any numbers after the decimal point, the number in the sheet may be rounded up.

Try this:

MyInteger = Range("D4").Text ' Converts to text
MyInteger = Int(MyInteger) ' converts back to an integer.
TextBox1.Value = MyInteger
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,417
Members
448,895
Latest member
omarahmed1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top