user form

  • Thread starter Thread starter Jase
  • Start date Start date
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.
 
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
 
Back
Top