im fairly new to VBA and excel (some experience in Python & R but a little rusty) and would like to know how i could code an IF ELSE statement to add data values of a cell to a listbox that i have displayed in the worksheet itself if they satisfy a condition? This is the code i have below with regards to the listbox i have displayed.
Private Sub Workbook_Open()
With Sheet1.ListBox1
.ColumnHeads = True
.ColumnCount = 1
.ListFillRange = Sheet2.ListObjects("Table2").DataBodyRange.Address(False, False, xlA1, True)
End With
End Sub
Sub loaddata()
Dim listdata As Object
Set listdata = Sheet1.ListBox1
Dim tabeldata As Range
Set tabeldata = Sheet2.Range("Table2")
With listdata
.AutoLoad = True
.ColumnHeads = True
.ColumnCount = 1
.List = tabeldata.CurrentRegion.Value
End With
End Sub