newbie: numberformat

  • Thread starter Thread starter Adri
  • Start date Start date
A

Adri

Hallo,
I have a list, filled by a range. The numbers that I get are for example
100. I want this to be 100.00 (two decimal).
I searched and think it has to be something with numberformat, but how to
fill in the code?

Private Sub Userform_Initialize()
ListBox1.List = Range("Werk").Value
End Sub
 
Looks to me like you need to format it when you add it to the list.
could not find a numberformat for a list box.

Try this:

ListBox1.AddItem Format(100, "#.00")
 
Hi Adri,

Don't like it, but here is one way

Private Sub Userform_Initialize()
Dim i As Long
ListBox1.List = Range("Werk").Value
For i = 0 To ListBox1.ListCount - 1
ListBox1.List(i) = Format(ListBox1.List(i), "#,##0.00")
Next i
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Private Sub Userform_Initialize()
Range("Werk").NumberFormat = "#.00"
for each cell in Range("Werk")
ListBox1.AddItem cell.Text
Next

End Sub
 
Thank you all, just what I needed.
Regards, Adri

Tom Ogilvy wrote:
| Private Sub Userform_Initialize()
| Range("Werk").NumberFormat = "#.00"
| for each cell in Range("Werk")
| ListBox1.AddItem cell.Text
| Next
|
| End Sub
|
|
| || Hallo,
|| I have a list, filled by a range. The numbers that I get are for
|| example 100. I want this to be 100.00 (two decimal).
|| I searched and think it has to be something with numberformat, but
|| how to fill in the code?
||
|| Private Sub Userform_Initialize()
|| ListBox1.List = Range("Werk").Value
|| End Sub
||
|| --
|| Kind regards,
|| Adri
 

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

Back
Top