#1   Report Post  
Posted to microsoft.public.excel.misc
gem.g
 
Posts: n/a
Default format a listbox

i need to format a listbox as im getting numbers such as 10.875421 and only
want 2 numbers after the decimal e.g. 10.87 can anyone help?
thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default format a listbox

You may want to share what that listbox is.

Is it on a userform?

Is it a listbox from the Forms toolbar placed on a worksheet?

Is it a listbox from the control toolbox toolbar placed on a worksheet?

I put a listbox from the control toolbox toolbar on a worksheet and used this
code in the worksheet_activate event -- not sure where you would want it to go.

Option Explicit
Private Sub Worksheet_Activate()
Dim myCell As Range
Dim myRng As Range

With Me
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Me.ListBox1
For Each myCell In myRng.Cells
.AddItem Format(myCell.Value, "00.00")
Next myCell
End With
End Sub

The important thing was the .additem stuff and the format statement.

"gem.g" wrote:

i need to format a listbox as im getting numbers such as 10.875421 and only
want 2 numbers after the decimal e.g. 10.87 can anyone help?
thanks


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditonal Format with a date format Kevin Excel Discussion (Misc queries) 2 April 27th 05 10:20 PM
Office2000: Conditional format behaves strangely Arvi Laanemets Excel Discussion (Misc queries) 1 April 7th 05 08:47 AM
can't format cell - have tried unlocking and unprotecting griffin Excel Discussion (Misc queries) 1 April 5th 05 02:11 AM
why does currency format change to number format? Cassie Excel Discussion (Misc queries) 3 March 18th 05 06:57 PM
Keep custom format in new worksheet Buddy Excel Discussion (Misc queries) 2 March 14th 05 10:03 AM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"