У меня есть следующий код, который выполняет некоторые if, но со значениями, которые я изо всех сил пытаюсь увидеть, как я создаю, и добавить значения в массив. На данный момент я просто добавляю значения в список
List(lC, 0) = sh1.Cells(row, 23)
Я попытался создать целое число, а затем использовал что-то вроде
var = var & List(lC, 0) = sh1.Cells(row, 23)
Но я не уверен, что это правильный путь?
Private Sub CommandButton3_Click()
Dim sh1
Dim LR
Dim lC
Dim row
Me.lstUsedRooms.Clear
Set sh1 = ThisWorkbook.Worksheets(4) 'room order from sheets
With sh1
LR = .Range("A" & .Rows.Count).End(xlUp).row
End With
lC = 0
With Me.lstUsedRooms
.ColumnCount = 1 'there is 8 columns
.RowSource = ""
.ColumnWidths = 40
For row = 2 To LR
NewIVTime = Format("14:00", "h:mm:ss")
If Left(sh1.Cells(row, 6), 10) = "24/05/2019" Then ' Gets all interviews for the date specified
Dim LTime As Date
Dim LTime1 As Date
LTime = Format(sh1.Cells(row, 7), "h:mm:ss") 'Gets the times from all the rooms from the date stated above
LTime1 = CDate(LTime) + 3 / 24 ' Adds 3 hours to the time above
If LTime1 < NewIVTime Then ' Check which interviews display three hours after the new interview
.AddItem
.List(lC, 0) = sh1.Cells(row, 23)
lC = lC + 1
End If
End If
Next
If .ListCount = 0 Then
Me.lstUsedRooms.ColumnWidths = 100
Me.lstUsedRooms.AddItem "No Rooms"
End If
End With
End Sub