user form

J

Jase

I am using a userform on an excel sheet that has a text box which reads
values off a designated cell in the sheet. On my userform the cell value is
rounded to about 8 decimal places and I would only like it to round to 1 or
2. Any idea how I would do that? On the excel sheet I have it rounded to 2
and that doesn't seem to work.
 
T

Tom Hutchins

One way... Load the cell value into a variable, use the Round function in VBA
to round it to as many decimals as you want, and assign the value of the
(rounded) variable to the textbox's value.

Private Sub UserForm_Initialize()
Dim CellVal As Double
CellVal# = Round(Sheets("Sheet1").Range("B30").Value, 2)
Me.TextBox1.Value = CellVal#
End Sub

Hope this helps,

Hutch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top