Hi There, I'm trying to create a userform that will allow one to select a subject from a combobox and populate the remaining controls with data from the corresponding spreadsheet. Here's the code I've been trying with no success:
Private Sub cboStudyID_Change()
'populate data on userform based on StudyID selection
Dim strNamedRange As String
Dim lRelativeRow As Long
With ComboBox1
If .ListIndex > -1 Then
strNamedRange = .RowSource
'ListIndex starts at zero
lRelativeRow = .ListIndex + 1
'Fill with adjacent column to Combobox choice
txtEnrollmentDate = Range(strNamedRange)(lRelativeRow, 2)
'Fill with 2nd adjacent column to Combobox choice
cboSite = Range(strNamedRange)(lRelativeRow, 3)
'Fill with 3rd adjacent column to Combobox choice
cboRetention = Range(strNamedRange)(lRelativeRow, 4)
End If
End With
End Sub
Attached is a simplified version of the .xlsm I'm working with....Any suggestions on how to make this work?
Bookmarks