Text boxes populating from Combo box

gadrummer65

New Member
Joined
Mar 6, 2014
Messages
9
Hello,
I have a code that mostly works. The only problem i am having is when the text boxes populate, they always populate the last item in my list, and not what i am clicking on. Any help would be greatly appreciated.

Code:
Private Sub ComboBox2_Click()

    Dim LR As Long
    Dim fRng As Range

    With Sheets("Hotels")
        LR = .Cells.Find("*", .Cells(Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                SearchDirection:=xlPrevious).Row

        Set fRng = .Range("A2:A" & LR)

        If Not .Aut**ilterMode Then
            .Range("A3").Aut**ilter
        End If
        .Range("A3:A" & LR).Aut**ilter Field:=1, Criteria1:=Me.ComboBox2.Value
        Me.tbResCol1.Value = .Aut**ilter.Range.**fset(1).SpecialCells(xlCellTypeVisible).Cells(0, 2).Value
        Me.tbResCol2.Value = .Aut**ilter.Range.**fset(1).SpecialCells(xlCellTypeVisible).Cells(0, 3).Value
        Me.tbResCol3.Value = .Aut**ilter.Range.**fset(1).SpecialCells(xlCellTypeVisible).Cells(0, 4).Value
        Me.tbResCol4.Value = .Aut**ilter.Range.**fset(1).SpecialCells(xlCellTypeVisible).Cells(0, 5).Value
        Me.tbResCol5.Value = .Aut**ilter.Range.**fset(1).SpecialCells(xlCellTypeVisible).Cells(0, 6).Value
        .Aut**ilterMode = False
    End With
    Me.ComboBox1.Enabled = True
End Sub
 
I did see that if i have a long list of hotels (IAH for example), no matter what hotel i choose, it only populates what seems to be the first hotel.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I was testing your sample, and if there is more than one hotel choice, it only populates the first one in the list.
 
Upvote 0
So how is the form to know which one you want to view?

The only way would be to add another column with a unique reference for each entry. I would always do that for a database type sheet
 
Upvote 0
When i click on the hotel name, i would like it to populate the information for that hotel in the text boxes. If there are multiple hotels, i would like it to populate the information of the hotel i click on.
 
Upvote 0
You need to identify which hotel it is. A lookup Function or .Find can only find the first instance, you can use .Findnext but it will still not know if it is the correct Hotel. You need some kind of reference to search for.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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