I'll start by thanking everyone in advance. So I have a matrix in Excel which essentially shows some category and sub-category areas. When the user clicks on the buttons/dropdowns I want the userform to show the text associated with their selection. i.e. if 'Strategy' is selected then 'Strategy Consultancy' then 'JLP Content' I then want all the different suppliers that fall under those categories to be listed - I've got that bit all working very well (thanks to some help I received on here last year - so thanks!).
Where I am struggling now is that behind every supplier name there would be a number of other bits of information that I would like to be displayed i.e. company address, telephone number etc so I created a separate sheet ('Supplier Data') with all the other columns I'd be interested in capturing and on the original sheet ("JLP Content") I have data validated dropdowns to select the supplier name from the 'Supplier Data' sheet.
I want my results userform to show all the columns info from the 'Supplier Data' sheet based on what supplier name has been selected from the data validation dropdown on sheet 'JLP Content'. I've attached the Excel file to make it all make sense. But here is the formula currently being used (which only returns the supplier name from sheet 'JLP Content'):
Private Sub cbResult_Click()Dim r As Long, Col As Long, i As LongDim Rng As Range, cel As RangeDim wArea4 As RangeDim WS As WorksheetDim iRes As IntegerDim strPrompt As StringDim strTitle As String ResultsScreen.rowCount = CalculateRowCount '<------------------------- On Error Resume Next Col = Cells(1, Columns.Count).End(xlToLeft).Column - 4 r = ResultsScreen.rowCount.Value Set Rng = Cells(r, 4).Resize(, Col).SpecialCells(xlCellTypeConstants) If Err Then Me.Show ResultsScreen.Hide 'User Prompt strPrompt = "No supplier found." 'Messagebox Title strTitle = "Error!" 'Messagebox Display iRes = MsgBox(strPrompt, vbExclamation + vbOKOnly, strTitle) Else Me.Hide ResultsScreen.Show ResultsScreen.lbResults.Clear End If For Each cel In Rng With lbResults .AddItem Cells(1, cel.Column) .List(.ListCount - 1, 1) = cel End With NextEnd SubPrivate Function CalculateRowCount() As LongDim Adjuster As LongWith Me If cboArea.ListIndex = 0 Then CalculateRowCount = 2 + cboSubCat.ListIndex Exit Function End If If .cboArea.ListIndex = 1 Then If .cboCategory.ListIndex = 0 Then CalculateRowCount = 11 Exit Function ElseIf .cboCategory.ListIndex = 1 Then Adjuster = 12 ElseIf .cboCategory.ListIndex = 2 Then Adjuster = 25 ElseIf .cboCategory.ListIndex = 3 Then Adjuster = 38 ElseIf .cboCategory.ListIndex = 4 Then CalculateRowCount = 43 Exit Function ElseIf .cboCategory.ListIndex = 5 Then CalculateRowCount = 44 Exit Function ElseIf .cboCategory.ListIndex = 6 Then Adjuster = 45 End If CalculateRowCount = Adjuster + cboSubCat.ListIndex Exit Function ElseIf .cboArea.ListIndex = 2 Then If .cboCategory.ListIndex = 0 Then CalculateRowCount = 49 + cboSubCat.ListIndex Exit Function ElseIf .cboCategory.ListIndex = 1 Then CalculateRowCount = 52 Exit Function ElseIf .cboCategory.ListIndex = 2 Then CalculateRowCount = 53 Exit Function ElseIf .cboCategory.ListIndex = 3 Then CalculateRowCount = 54 Exit Function End If End If If .cboArea.ListIndex = 3 Then CalculateRowCount = 55 Exit Function End IfEnd WithEnd Function