I have a spreadsheet called Eque2_Contracts that contains various columns of data. The first column A contains multiple codes, for example 00120, 00130 etc from A2 downwards. This can be added to with new records at any time.
I also have a combobox1 that lists all individual codes from this first column. I also then have a listbox1.
When combobox1 value is selected, I want the script to check A2, A3, A4 etc in my spreadsheet against that combobox1 value. If it finds the combobox1 value in cell A2, A3, A4 I want it to list cell B2 data into listbox1. (The adjacent info)
BUT I need it to search ALL of column A, as the codes can appear more than once. Each time it finds the combobox1 value in column A, I need the data in the adjacent B cell added to the listbox.
Each time a new combobox1.value is selected, it needs to clear the listbox1, search again as above for the occurrences of that code and copy the adjacent data in column B into the listbox.
I got this far (thinking I should create a library containing both columns of data for faster searching) now unsure how to check that data?
Dim Cl As Range
Dim Dic As Object
Set Dic = CreateObject("scripting.dictionary")
With Sheets("Eque2_Contracts")
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Array(Cl, Cl.Offset(, 1).Value)
Next Cl
End With
Any help would be much appreciated.
I also have a combobox1 that lists all individual codes from this first column. I also then have a listbox1.
When combobox1 value is selected, I want the script to check A2, A3, A4 etc in my spreadsheet against that combobox1 value. If it finds the combobox1 value in cell A2, A3, A4 I want it to list cell B2 data into listbox1. (The adjacent info)
BUT I need it to search ALL of column A, as the codes can appear more than once. Each time it finds the combobox1 value in column A, I need the data in the adjacent B cell added to the listbox.
Each time a new combobox1.value is selected, it needs to clear the listbox1, search again as above for the occurrences of that code and copy the adjacent data in column B into the listbox.
I got this far (thinking I should create a library containing both columns of data for faster searching) now unsure how to check that data?
Dim Cl As Range
Dim Dic As Object
Set Dic = CreateObject("scripting.dictionary")
With Sheets("Eque2_Contracts")
For Each Cl In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Array(Cl, Cl.Offset(, 1).Value)
Next Cl
End With
Any help would be much appreciated.