![]() |
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 |
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 |
All times are GMT +1. The time now is 07:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com