I'm not very experienced at working with arrays in vba and this is probably very simple.
I want to populate a listbox with an array of unknown size (three columns, not sure how many rows) from the sheet "SAP Codes" starting from row 2.
The code I have below doesn't seem to work.
Dim arrSAPCodes() As String
Private Sub UserForm_Initialize()
'Populate SAP Codes
arrSAPCodes = .Range(.Range("A2"), .Range("C" & Rows.Count).End(xlUp))
lstSAPCodes = SAPCodes
End Sub
I'm sure it's something obvious
Incidentally, when I have done this, how do I refer to an individual item of the array? For example, if the first column contains unique code and I have a unique code, how do I find the corresponding entry in the second column?
I want to populate a listbox with an array of unknown size (three columns, not sure how many rows) from the sheet "SAP Codes" starting from row 2.
The code I have below doesn't seem to work.
Dim arrSAPCodes() As String
Private Sub UserForm_Initialize()
'Populate SAP Codes
arrSAPCodes = .Range(.Range("A2"), .Range("C" & Rows.Count).End(xlUp))
lstSAPCodes = SAPCodes
End Sub
I'm sure it's something obvious
Incidentally, when I have done this, how do I refer to an individual item of the array? For example, if the first column contains unique code and I have a unique code, how do I find the corresponding entry in the second column?