Like this, as an example in your sample workbook, change some of the Person Names to OPEN
Public Sub GetInfoFromSomewhere(Optional ByRef CompanyInfo)
Const keyWord As String = "OPEN" 'Word to check
Const columnNo As Long = 4 'Column number to check
Dim temp
Dim temp2()
Dim x As Long, y As Long
Dim colOpens As Object
With Sheets("Sheet1").Cells(1, 1).CurrentRegion
temp = .Offset(1).Resize(.Rows.Count - 1).Value
End With
Set colOpens = CreateObject("Scripting.dictionary")
ReDim temp2(0 To UBound(temp, 2))
For x = LBound(temp) To UBound(temp)
If temp(x, 4) = keyWord Then
For y = LBound(temp, 2) - 1 To UBound(temp, 2) - 1
temp2(y) = temp(x, y + 1)
Next y
colOpens(colOpens.Count) = temp2
End If
Next x
CompanyInfo = colOpens.items
End Sub
Public Sub FillListView()
Dim CompanyInfo As Variant
Dim column_header As ColumnHeader
Dim Astr As String
Dim Along As Long
Dim avar As ListItem
With LvTest
.ListItems.Clear
.ColumnHeaders.Add , , "Report No", 120
.ColumnHeaders.Add , , "Date Reised", 120
.ColumnHeaders.Add , , "Report Type", 100
.ColumnHeaders.Add , , "Recipient Name", 100
.HideColumnHeaders = False
End With
Call GetInfoFromSomewhere(CompanyInfo)
With LvTest
.View = 3 'determines style of the listview
For i = LBound(CompanyInfo) To UBound(CompanyInfo)
Set avar = .ListItems.Add(i + 1, , CompanyInfo(i)(0))
For ii = LBound(CompanyInfo(i)) + 1 To UBound(CompanyInfo(i)) - 1
avar.SubItems(ii) = CompanyInfo(i)(ii)
Next ii
ii = 1
Next i
End With
End Sub
Bookmarks