Search box that allows you to start typing and it will autofill the answer matching file names

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a spreadsheet that I want to have something that allows me to start typing a name and it will auto fill as I type to match the name typed with the names on other spreadsheets that are kept in a folder called Young People that is within the folder of the spreadsheet. I am not sure how to do this, could someone give me some guidance please?

After enough letters are typed in and the correct name appears, I want to be able to press a button and have the relevant document open.

Thanks
 
shape1.png
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Thanks Michael, I just had found it.

Ok, so now I have worked that bit out. I have a drop down list that autocompletes from a list stored on another worksheet.

Now I need some way to open a file on the young person once I have the correct name. Maybe a button underneath that I have to select. The files for the young people will be called the same as the names from the list and will have have the same directory structure as described in post 1.

Although, what I would really like is to press enter and for the other spreadsheets to open.
 
Upvote 0
I have tried to write some code to open the files from the item selected but it said that the file was not found. What is wrong with my code?

VBA Code:
Sub OpenFile()
    Dim dd As DropDown, SelectedItem As String
    
    Set dd = ActiveSheet.Shapes(Application.Caller).OLEFormat.Object
    SelectedItem = dd.List(dd.ListIndex)
    
    Workbooks.Open Filename:=ThisWorkbook.Path & "\Young People\" & SelectedItem & ".xlsm"
End Sub
 
Upvote 0
I believe You need to refer to the cell that is populated, not the list itself.
If the linked cell is say A1, use
VBA Code:
Sub OpenFile()
    Dim SelectedItem As String
    SelectedItem =cells(1,1).value
   Workbooks.Open Filename:=ThisWorkbook.Path & "\Young People\" & SelectedItem & ".xlsm"
End Sub
 
Upvote 0
But it is not a cell that gets populated, the combo box does.
 
Upvote 0
Actually, I worked that out Michael, thanks for your help :)
 
Upvote 0
How would I do it if I wanted the code to execute upon pressing enter while typing in the combo box?
 
Upvote 0
USe a change event
VBA Code:
Private Sub TempCombo_Change()
Call MyMacro
End Sub
 
Upvote 0
Wouldn't That call the sub for each keystroke, not just pressing Enter?
 
Upvote 0
did you try it ??
I'm guessing without testing that the new change to the combo box won't take effect until you enter.
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,706
Members
449,331
Latest member
smckenzie2016

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