referencing combobox value to populate lines in textbox with proper entries

Watchdawg

Board Regular
Joined
Jan 21, 2015
Messages
84
I've looked around and I'm having some trouble finding this (probably not wording it right).
I have a list of functions in A5:A50
A list of names spans D3:V3
D5:V50 involves boxes containing "C", "R", or "I" referencing that they have a responsibility in the function in column A

The userform populates from the functions in A, so when that changes, a textbox populates. What I need is the textbox to populate with a list of names (each on a single line) that have the C, R or I designator in the box matching both the name and the function.

Wow, I really hope that came across correctly.
Anyone that can help? Or lead me to a thread that I've missed?
 

Attachments

  • example1.JPG
    example1.JPG
    77.4 KB · Views: 11
  • image_2022-03-21_130749.png
    image_2022-03-21_130749.png
    5.4 KB · Views: 11
Forget all of the above, use the following to populate textbox1 and textbox2.

VBA Code:
Private Sub ComboBox1_Change()
  Dim f As Range
  Dim sh As Worksheet
  Dim i As Long, j As Long
  
  With TextBox2
    TextBox1.Value = ""
    .MultiLine = True
    .Value = ""

    Set sh = Sheets("Functional Contacts")
    Set f = sh.Range("A:A").Find(ComboBox1.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      i = f.Row
      For j = 4 To sh.Cells(i, Columns.Count).End(1).Column
        Select Case sh.Cells(i, j).Value
          Case "C", "R", "I"
            .Value = .Value & vbCr & sh.Cells(3, j)
        End Select
      Next
      
      TextBox1.Value = sh.Range("C" & i).Value
      
    End If
  End With
End Sub
 
Upvote 0
Solution

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I can't download your file because it asks me to sign up for dropbox.

But I think you're using the RowSource property of the combobox as follows:

1647958656558.png


If not, also forget it, try the code of the post #11
 
Upvote 0
Forget all of the above, use the following to populate textbox1 and textbox2.

VBA Code:
Private Sub ComboBox1_Change()
  Dim f As Range
  Dim sh As Worksheet
  Dim i As Long, j As Long
 
  With TextBox2
    TextBox1.Value = ""
    .MultiLine = True
    .Value = ""

    Set sh = Sheets("Functional Contacts")
    Set f = sh.Range("A:A").Find(ComboBox1.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      i = f.Row
      For j = 4 To sh.Cells(i, Columns.Count).End(1).Column
        Select Case sh.Cells(i, j).Value
          Case "C", "R", "I"
            .Value = .Value & vbCr & sh.Cells(3, j)
        End Select
      Next
     
      TextBox1.Value = sh.Range("C" & i).Value
     
    End If
  End With
End Sub
Thank you so much! That worked like a charm, I really appreciate your patience.
 
Upvote 0

Forum statistics

Threads
1,215,970
Messages
6,127,991
Members
449,414
Latest member
sameri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top