hi all I have a table with two columns of data, As below
In a userform i have two comboboxes which on form initilisation each load with one of the two columns of data from table above. The click event in each of the two cmb activates a xlookup which populates the other cmb with the corresponding data from the table. I have posted the two bits of code below
2
My problem is like this. Both cmb boxes are set to match required. The combo that contains letters is fine. The cmb with the numbers doesn't recognize any match, even when I simply use the drop arrow and select a number from the drop list.
I know this has something to do with the code click event because when i delete the code, it works fine. Why this is happening though, I haven't a clue - any idea?
Column1 | Column2 |
1 | ג' תשס |
2 | ג' תשסא |
3 | ג' תשסב |
In a userform i have two comboboxes which on form initilisation each load with one of the two columns of data from table above. The click event in each of the two cmb activates a xlookup which populates the other cmb with the corresponding data from the table. I have posted the two bits of code below
VBA Code:
Private Sub ComboNewArtistDODJ_Click()
ComboNewArtistDODG.Value = ""
Dim searchValue As String
Dim searchRange As Range
Dim tableData As Range
Dim resultRange As Range
searchValue = ComboNewArtistDODJ.Value
Set searchRange = Worksheets("Helper Data").ListObjects("Table4").ListColumns(2).DataBodyRange
Set tableData = Worksheets("Helper Data").ListObjects("Table4").ListColumns(1).DataBodyRange
Set resultRange = WorksheetFunction.XLookup(searchValue, searchRange, tableData)
ComboNewArtistDODG.Value = resultRange
End Sub
2
Code:
Private Sub ComboNewArtistDODG_Click()
ComboNewArtistDODJ.Value = ""
Dim searchValue As Long
Dim searchRange As Range
Dim tableData As Range
Dim resultRange As Range
searchValue = ComboNewArtistDODG.Value
Set searchRange = Worksheets("Helper Data").ListObjects("Table4").ListColumns(1).DataBodyRange
Set tableData = Worksheets("Helper Data").ListObjects("Table4").ListColumns(2).DataBodyRange
Set resultRange = WorksheetFunction.XLookup(searchValue, searchRange, tableData)
ComboNewArtistDODJ.Value = resultRange
End Sub
My problem is like this. Both cmb boxes are set to match required. The combo that contains letters is fine. The cmb with the numbers doesn't recognize any match, even when I simply use the drop arrow and select a number from the drop list.
I know this has something to do with the code click event because when i delete the code, it works fine. Why this is happening though, I haven't a clue - any idea?