listbox number formats

xl factor

New Member
Joined
Jun 1, 2011
Messages
2
Hello,

I use the below code to populate a listbox on a user form. It works fine except that it does not retain the number formats from the worksheet.
I need Column no.7 & 10 to show 4 digits (if the number is 10, it must show 0010) and column no 8 & 11 to show 3 digits (if the number is 5, It must show 005).

Hope someone out there can help me out with this issue.
Regards

Code:
Private Sub ComboBox3_Change()

Dim rowCount As Integer
Dim myArray() As Variant

With ComboBox3
If ComboBox3.Value = "ALL" Then
Sheets("Movement Box").Cells.Clear
Sheets("B1 Movements").Select
Range("A2").Select
Selection.AutoFilter Field:=2, Criteria1:="ALL"
Range("A3:O3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    Range("A2").Select
    Sheets("Movement Box").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A1").Select
    Sheets("B1 Movements").Select
    Application.CutCopyMode = False
Sheets("Movement Box").Select
'get row count and fill array
rowCount = Cells(Rows.Count, "A").End(xlUp).Row
myArray = Range("A1:O" & rowCount).Value

'fill listBox3
ListBox3.ColumnCount = 15
myArray = WorksheetFunction.Transpose(myArray)
Me.ListBox3.Column = myArray
End if
End with
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top