VB Help with textbox property

K

K1KKKA

Am using the code below to show data entered into Sheet "T", but in
each textbox i would only like to see 2 decimal points, how would i
achieve this, can not see how in the properties box in Vb, was
expecting it to be that easy. i presumed using the "format ( date,
dd,mmm,yy) would fix this, but maybe im using it wrong?


any help please!!


Steve
===============================

Private Sub ComboBox1_Change()
Dim iRow As Long


With Me
iRow = .ComboBox1.ListIndex + 7
.TextBox1.Text = Worksheets("T").Cells(iRow, "c").Value
.TextBox2.Text = Worksheets("T").Cells(iRow, "d").Value
.TextBox3.Text = Worksheets("T").Cells(iRow, "e").Value
.TextBox4.Text = Worksheets("T").Cells(iRow, "f").Value
.TextBox5.Text = Worksheets("T").Cells(iRow, "p").Value
.TextBox6.Text = Worksheets("T").Cells(iRow, "q").Value
.TextBox7.Text = Worksheets("T").Cells(iRow, "u").Value
.TextBox8.Text = Worksheets("T").Cells(iRow, "x").Value
.TextBox9.Text = Worksheets("T").Cells(iRow, "y").Value
.TextBox10.Text = Worksheets("T").Cells(iRow, "z").Value
.TextBox11.Text = Worksheets("T").Cells(iRow, "ac").Value
.TextBox12.Text = Worksheets("T").Cells(iRow, "ad").Value
.TextBox13.Text = Worksheets("T").Cells(iRow, "ae").Value
.TextBox14.Text = Worksheets("T").Cells(iRow, "ag").Value
.TextBox15.Text = Worksheets("T").Cells(iRow, "ah").Value
.TextBox16.Text = Worksheets("T").Cells(iRow, "ai").Value
.TextBox17.Text = Worksheets("T").Cells(iRow, "aj").Value
.TextBox18.Text = Worksheets("T").Cells(iRow, "al").Value
End With
End Sub
-----------------------------------------------------------------------------------------------------

Private Sub UserForm_Activate()
Dim iLastRow As Long
Dim i As Long


With Worksheets("T")
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Me.ComboBox1.Clear
For i = 7 To iLastRow
Me.ComboBox1.AddItem .Cells(i, "A").Value
Next i
End With
End Sub
 
D

Dave Peterson

I'm not sure how 2 decimal points and the date format fits in, but maybe
something like:

..TextBox1.Text = format(Worksheets("T").Cells(iRow, "c").Value, "0.00")
 
K

K1KKKA

I'm not sure how 2 decimal points and the date format fits in, but maybe
something like:

.TextBox1.Text = format(Worksheets("T").Cells(iRow, "c").Value, "0.00")










--

Dave Peterson- Hide quoted text -

- Show quoted text -

Sorry Dave, there were 2 questions but did not explain it very well,
thanks for help on 1st question, would i use similar answer to get
date format to work in combobox1?
I use this field to pull back the data by Date, currently it list the
date format as MM DD YY, but would like the combobox1 to show date by
DD MM YY.


Steve
 
D

Dave Peterson

If those are really dates in column A (just formatted that way):

Me.ComboBox1.AddItem format(.Cells(i, "A").Value, "dd mm yy")

If they're not really dates, I'd suggest that you change them to dates
 
K

K1KKKA

If those are really dates in column A (just formatted that way):

Me.ComboBox1.AddItem format(.Cells(i, "A").Value, "dd mm yy")

If they're not really dates, I'd suggest that you change them to dates








--

Dave Peterson- Hide quoted text -

- Show quoted text -

Once again this site shows how helpful you all are, many thanks worked
a treat


Steve
 

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