Hey,
I am working on a bit of code that will read data from a series of columns in a database, a dropdown menu is used to display unique values from one of the columns. I then want to read the value that has been selected from this dropdown and then display a value in the same row but on a different column in a separate listbox (similar to vlookup). The code I have works with a database full of strings but falls down when the values in the dropdown are number (error type mismatch).
I think this is a problem with the .List method of the dropdown it simply refuses to read numbers, even when the column arrar I am reading from is stored as variant.
I hope I have explained my problem clearly, if not please ask, I appreciate any help that someone can give me. Full code or spreadsheet is available upon request.
Thanks in advance
PS here is the part of the code that reads the value selected from the dropdown and produces the corresponding value from a different column in a list box. As I say it works perfectly when the value in the dropdown is a string but refuses to work with numbers.
Sub LoadPressures()
Dim listSeatDia
Dim Data
Dim UniquePressures
Dim Pressures
'Selects data range to be worked upon
With Worksheets("Data")
Data = Intersect(.UsedRange, .Range("k:q"))
End With
'Removes all items from the list box
Sheet1.ListBoxes("Concat_SD_P").RemoveAllItems
'Reads what value is selected in the dropdown, this will effect what is shown in the listbox
With Sheet1.DropDowns("SeatDia")
listSeatDia = .List(.ListIndex)
End With
'This pulls data that is selected in column 1 and replaces it with data
'on column 7 in the same row
UniquePressures = UNIQUEVALUES(Data, listSeatDia, 1, 7)
Pressures = SORTSDARRAY(UniquePressures, Ascending)
'lists all of the unique items in column 7 that have been selected and places these in the list box
For i = 0 To UBound(Pressures, 1)
ListBoxes("Concat_SD_P").AddItem Pressures(i)
Next
End Sub
I am working on a bit of code that will read data from a series of columns in a database, a dropdown menu is used to display unique values from one of the columns. I then want to read the value that has been selected from this dropdown and then display a value in the same row but on a different column in a separate listbox (similar to vlookup). The code I have works with a database full of strings but falls down when the values in the dropdown are number (error type mismatch).
I think this is a problem with the .List method of the dropdown it simply refuses to read numbers, even when the column arrar I am reading from is stored as variant.
I hope I have explained my problem clearly, if not please ask, I appreciate any help that someone can give me. Full code or spreadsheet is available upon request.
Thanks in advance
PS here is the part of the code that reads the value selected from the dropdown and produces the corresponding value from a different column in a list box. As I say it works perfectly when the value in the dropdown is a string but refuses to work with numbers.
Sub LoadPressures()
Dim listSeatDia
Dim Data
Dim UniquePressures
Dim Pressures
'Selects data range to be worked upon
With Worksheets("Data")
Data = Intersect(.UsedRange, .Range("k:q"))
End With
'Removes all items from the list box
Sheet1.ListBoxes("Concat_SD_P").RemoveAllItems
'Reads what value is selected in the dropdown, this will effect what is shown in the listbox
With Sheet1.DropDowns("SeatDia")
listSeatDia = .List(.ListIndex)
End With
'This pulls data that is selected in column 1 and replaces it with data
'on column 7 in the same row
UniquePressures = UNIQUEVALUES(Data, listSeatDia, 1, 7)
Pressures = SORTSDARRAY(UniquePressures, Ascending)
'lists all of the unique items in column 7 that have been selected and places these in the list box
For i = 0 To UBound(Pressures, 1)
ListBoxes("Concat_SD_P").AddItem Pressures(i)
Next
End Sub