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
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