RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Greetings,
I have a 2-D array (variable # of rows, 6 columns), I'm looking to go down the second column and convert a number (between 0 and 1) into a time. Trying a few things but unsuccessful. I can index the column (confirmed through debug.Print) but am incorrectly attempting to apply a format to each item in that second column. As an aside, the array subsequently is placed into a listbox (works but time numbers are in 0.00 format)
Attempt
I have a 2-D array (variable # of rows, 6 columns), I'm looking to go down the second column and convert a number (between 0 and 1) into a time. Trying a few things but unsuccessful. I can index the column (confirmed through debug.Print) but am incorrectly attempting to apply a format to each item in that second column. As an aside, the array subsequently is placed into a listbox (works but time numbers are in 0.00 format)
Attempt
VBA Code:
Private Sub SummarizeData()
Dim wSht As Worksheet
Dim rRange As Range
Dim tempArray() As Variant
Dim item As Variant
Set wSht = ThisWorkbook.Worksheets("RawData")
Set rRange = wSht.Range("rngData")
tempArray = rRange.Value
For Each item In Application.Index(tempArray, 0, 2)
item = Format(item, "h:mm AM/PM")
Next item
Me.lbHistory.List = tempArray
End Sub