In this tutorial we will use a list of 87 names that as we type into the drop down list, it searches the names, and the list shortens to show only those names containing that string of characters.

There are a few formulas to write to get this done. Everything is shown and provided in this tutorial. If you prefer a video. Check out the video tutorial below.

The drop down list used here is the combo box control. It is not a Data Validation list. So the first task is to insert a combo box control where you want the list to be.

- Click the
**Developer**tab on the Ribbon (don’t have a Developer tab? Right click the Ribbon, select Customise the Ribbon and check the Developer on the right). - Click the
**Insert**button in the Controls group and select the**Combo Box (ActiveX Control)**.

- Click and drag to draw this control onto the worksheet. You can always move and resize the control later, so don’t worry about 100% accuracy.
- Now we need to link the combo box value to a cell. After inserting the combo box, you should already be in design mode. Click the
**Properties**button on the Developer tab. If this is not active, click the**Design Mode**button and then**Properties**. - The Properties window appears. In the
**LinkedCell**property, type the cell address of the cell you want the combo box linked to.

- Let’s check out what we currently have. Click the
**Design Mode**button to exit design mode. Type into the combo box and you should see the value appearing in the cell you linked it to.

To be able to create this searchable list, the first formula will need to identify which names meet the criteria and should continue to appear in the list when the user is typing.

To identify the names that contain the characters being searched for, we will use an Excel function with a very appropriate name – the SEARCH function.

The SEARCH function below can be used.

=SEARCH($G$1,A2)

In this function, cell $G$1 is the cell that the combo box is linked to. So this contains the string of characters that we are looking for. Cell A2 is the first name in the list of names.

This function will return the *#VALUE!* error if a name does not contain the characters typed, and returns the first occurrence of those characters if it does.

In the image below you can see that the characters being searched occur in the fifth position of the names in A2 and A3, in position 1 of A6 and not at all in the other cells.

Now this is what we need. We now know which names should be appearing in the final drop down list while users are searching.

However, I don’t like the *#VALUE!* error and I’m not really interested in what position the characters are in. I just need to know that they are there.

The ISNUMBER function can then be added to the SEARCH function so that it returns TRUE or FALSE when a name is identified or not. The double negative is then added before the ISNUMBER function to convert the TRUE or FALSE to 1 or 0.

=--ISNUMBER(SEARCH($G$1,A2))

The next formula needs to count how many names in the list contain the characters being searched for.

This is important to create the dynamic aspect of the searchable drop down list. As characters are typed the list should shrink, and then expand again when the characters are deleted.

The COUNTIF function is used here to count the occurrences of names being returned. This function uses a reference to the ‘IF Found’ column in B. It has a fixed start point of $B$2, but a relative row number on the end point $B2. This ensures that the reference gets bigger as the formula is copied down.

It is counting how many times a 1 occurs in the range up to the point of the current row.

COUNTIF($B$2:$B2,1)

An IF function can then be added to it so that it only performs the COUNTIF, if the cell contains a 1, otherwise show blank in the cell.

=IF(B2=1,COUNTIF($B$2:$B2,1),"")

We now know which names should be appearing in the list, and we also know how many there are.

Next step is to create a range of cells containing these names only. A drop down list can then use this range of cells.

To lookup these names we can use the amazing INDEX and MATCH function combination.

=INDEX($A$2:$A$88,MATCH(ROWS($C$2:$C2),$C$2:$C$88,0))

The INDEX function is used here to return a name from the range A2:A88 from the row specified by the MATCH function.

The ROWS function is used to return the current row number. So for the first name in the list it is row 1 of that range. The second name is row 2 and so on. This works to provide MATCH with the current name we are looking for (1st, 2nd etc).

The MATCH function then looks for this number in range C2:C88. It reports back to INDEX with the names position, and INDEX extracts the name.

The IFERROR function can then be added to this so that the cell contains blank if there are no more names to look for.

=IFERROR(INDEX($A$2:$A$88,MATCH(ROWS($C$2:$C2),$C$2:$C$88,0)),"")

Now that we have the returned names, we need an easy way of referring to them. For this we will create a named range. This will need to be dynamic and detect how many names are returned. The combo box will then use this named range for its list.

Click the **Formulas** tab on the Ribbon and then **Define Name**. Enter a name for the range (I named it *employees*) and then enter the formula like below into the **Refers to** field.

=$D$2:INDEX($D$2:$D$88,COUNTIF($D$2:$D$88,"?*"))

To __create the dynamic named range__ we used the INDEX function with COUNTIF. The INDEX function is capable of returning a value or a reference and in this scenario we need it for the latter.

The dynamic range starts from $D$2 and then the COUNTIF function is used to locate the last name in the list for the INDEX function. The “?*” is used as the criteria to count the number of cells containing text.

Now that we have the searchable list of names in a column and the range has been named. The combo box needs to be told to use this named range as its source.

- Click the
**Developer**tab on the Ribbon and then the**Design Mode**button. - Now we are in design mode, click on the combo box control and then click the
**Properties**button. - Type the name that you gave your named range into the
**ListFillRange**field.

- Close the properties window.

The final step is to make sure the list drops down when somebody types into it. At the moment someone could click the list arrow to drop it down, but if they type, no list appears.

- Double click on the combo box (you need to still be in design mode for this).
- This will take you to a code window to enter a tiny piece of VBA code. Type the line below in between the
*Private Sub*and*End Sub*lines.

Private Sub ComboBox1_Change() ComboBox1.DropDown End Sub

Adjust the *Combobox1* part to the name of your combo box.

If you are interested in learning VBA then check out our Excel VBA online course. It is a fantastic skill to have if you are a heavy Excel user.

Exit design mode and test out your combo box. You should now have a searchable drop down list to use on your Excel reports, dashboards and forms. Everyone will be asking how you did it.

The spreadsheet below shows a list of names with the answer in cell D2. *Ross* is the name that occurs the least in that list.

This formula returns the least frequent value from the list in A2:A16. The formula is explained below so keep reading.

{=INDEX(A2:A16,MATCH(MIN(COUNTIF(A2:A16,A2:A16)),COUNTIF(A2:A16,A2:A16),0))}

This formula is an array formula so you need to press **Ctrl + Shift + Enter**, and not **Enter**. This will put the curly braces around the formula. You do not type these.

Within this formula the COUNTIF functions are used to return how many times each name occurs in the list. The COUNTIF functions return the result below;

{2;5;5;4;4;5;4;4;5;2;4;5;4;4;4}

This means that the name in the first cell of that range (A2) occurs twice, 2nd cell (A3) occurs five times, 3rd cell (A4) occurs five times and so on.

The MIN function returns the smallest number from that array, which is 2 in this example.

The MATCH function is then used to search for the position of the first instance of 2 (the least mentioned names position). The result of this is 1, because the first instance of 2 is in the first cell of range A2:A16.

The INDEX function then returns the value which is in that cell (A2). Which in this example is *Ross*. Watch the video below for a visual explanation of this formula.

The INDEX and MATCH functions are awesome when used together for a flexible lookup formula. Find out more at this INDEX and MATCH tutorial.

Seriously improve your Excel Formula skills with our online course. Over 100 formulas covered. Sign Up Now.

]]>It may be a neat way of deciding who is next to do the washing up, or to make the tea :). Or it is useful for randomly drawing teams for a knockout cup competition.

To perform this random selection, we are going to use two different functions together. They are INDEX and RANDBETWEEN.

The INDEX function is used to return a value from a given cell in a range, and the RANDBETWEEN function is used to calculate a random number between two given numbers.

When used together, we can get the INDEX function to return a value (a persons name) from a random cell within its range.

The following formula has been entered into cell C3 to return a name at random from the list in A2:A13.

=INDEX(A2:A13,RANDBETWEEN(1,12))

The INDEX function used the 12 cells from A2:A13 as its array. The RANDBETWEEN function is then told to generate a random number between 1 and 12 and INDEX returns the value from that cell within its range.

So for example, if RANDBETWEEN returns the number 4, then INDEX returns the name from cell A5.

Want to learn more awesome formulas like this? Check out our Excel Formulas Made Easy online course.

The RANDBETWEEN function is a volatile function. This means that it calculates every time Excel does. Not all functions work this way, and normally only calculate when necessary to do so.

Because of this you may want to switch from automatic calculations to manual, otherwise the formula will constantly generate a random name, and not just when you need one.

To do this, click the **Formulas** tab on the Ribbon, then click **Calculation Options** and then **Manual**.

Now, to run calculations on the worksheet you can press **F9**.

By **adding a scroll bar to the chart**, users can interact with the chart and scroll to see the data they want displayed.

In this example, we have a spreadsheet with revenue for the last 23 months. As this is a lot of data to plot, we have decided that the chart will only display 5 months at a time. A scroll bar will be added so that users can scroll through the years.

The screenshot below shows the 23 months of revenue on the spreadsheet.

Download the spreadsheet to follow along

Our first task will be to create a condensed version of this table only showing the 5 months that the chart will use as its source.

- On a new worksheet, enter 1 in cell A2. The reason for this number will become clearer as we go on. Essentially this value will change as the user scrolls on the chart. It stores the row number of the data to return for the chart.
- Write the following the INDEX function in cell A4.

=INDEX(‘All Data’!$A4:$A$26,Chart!$A$2)

The INDEX function is used in Excel to return a value from a specified row and column. Its syntax is;

=INDEX(*array*, *row_num*, [*column_num*])

In this instance we are using it to return the value from column A that is in the row number stored in cell A2 of the *Chart* sheet.

There is no dollar sign before row 4 in the formula. This is important, as it ensures that when we copy the formula down, the row number will change. All other parts of the reference are fixed.

- Copy the formula down to cell A8.
- Enter the formula below in cell B4.

=INDEX(‘All Data’!$B4:$B$26,Chart!$A$2)

- Copy the formula down to cell B8.

Now that we have the data source, its time to create the chart.

- Select range A3:B8.
- Click the
**Insert**tab,**Line**and select a Line graph. - Perform any formatting options you want for better presentation. In the example below I have removed the Legend, removed the value axis and gridlines, and also added the values as data labels to the chart.

The final stage and the one we have been waiting for is to add the scrollbar to the chart.

- Click the
**Developer**tab on the Ribbon.

**Note:** If the Developer tab is not visible, click **File** > **Options** > **Customize Ribbon** and check the **Developer** box on the right.

- Click the
**Insert**button and select the**Scroll Bar ( Form Control)**from the menu.

- Click and drag to draw the scroll bar onto the worksheet underneath the chart.
- Click on the
**Properties**button on the Developer tab, or right mouse click the scroll bar and select**Format Control**. - The Format Control dialog box opens. Ensure the
**Control**tab is selected. - Enter 1 in the
**Current value**field. - Type 1 for the
**Minimum value**. The lowest row number in the table is number 1. - Enter 19 for the
**Maximum value**. There are 23 months of data. By displaying 5 months on the chart at any time the maximum row number must be 19. - Type 1 for the
**Incremental change**. This is the number of months the chart scrolls when the scroll bar arrow are clicked. - Enter 5 in the
**Page change**field. This is the number of months that the chart scrolls when you click within the scroll bar. - Click in the
**Cell link**field and then select cell A2 on the sheet. The reference $A$2 should appear in the field. This is the cell containing the row number to return for the chart. The scroll bar will change this when used.

- Click
**Ok**.

Click elsewhere on the spreadsheet to make the scroll bar active. Now when used the chart changes the information that is displayed.