Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,227
- Office Version
- 2010
- Platform
- Windows
I want to display 7 entries from columns A and G of a worksheet (sheet1) in a userform listbox. I am using the following code to populate the listbox and it is working fine except the time (in column B) is in decimal form instead of AM/PM form (.861643518518519 = 8:40 PM). Can someone help me modify this code to include a format function that displays the proper time in the listbox please?
VBA Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim rng As Range
Dim MyArray
Set ws = Sheets("Sheet1")
Set rng = ws.Range("A1:G" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)
With Me.ListBox1
.Clear
.ColumnHeads = False
.ColumnCount = rng.Columns.Count
MyArray = rng
.List = MyArray
.ColumnWidths = "50;60;70;50;60;60;50"
.TopIndex = 0
End With
End Sub