What's new

Help Phc bot

Kuromi

Journeyman
Create an excel file that has a city municipality and dropdown list that constantly changes based on choices using indirect or offset
 
Solution
To create an Excel file with a city municipality and a dropdown list that constantly changes based on choices using the INDIRECT or OFFSET function, you can follow these steps:

Step 1: Prepare the Data
  • In a new worksheet, create two columns: "City" and "Municipality".
  • Enter the list of cities in the "City" column.
  • Enter the corresponding municipalities in the "Municipality" column, matching the cities.

Step 2: Define Named Ranges
  • Select the range of cities (excluding the header) and click on the "Formulas" tab.
  • In the "Defined Names" group, click on "Create from Selection".
  • Choose the option "Left Column" and click OK.
  • The range of cities is now defined as a named range. Let's assume it is named...
To create an Excel file with a city municipality and a dropdown list that constantly changes based on choices using the INDIRECT or OFFSET function, you can follow these steps:

Step 1: Prepare the Data
  • In a new worksheet, create two columns: "City" and "Municipality".
  • Enter the list of cities in the "City" column.
  • Enter the corresponding municipalities in the "Municipality" column, matching the cities.

Step 2: Define Named Ranges
  • Select the range of cities (excluding the header) and click on the "Formulas" tab.
  • In the "Defined Names" group, click on "Create from Selection".
  • Choose the option "Left Column" and click OK.
  • The range of cities is now defined as a named range. Let's assume it is named "Cities".
  • Repeat the above steps to define a named range for the municipalities. Let's assume it is named "Municipalities".

Step 3: Create the Dropdown List
  • In a different worksheet or in a new column next to your existing data, select the cell where you want the dropdown list to appear.
  • Go to the "Data" tab and click on "Data Validation" in the "Data Tools" group.
  • In the "Data Validation" dialog box, under the "Settings" tab, choose "List" in the "Allow" drop-down menu.
  • In the "Source" field, enter the following formula: =INDIRECT("Cities"). This will reference the named range created earlier.
  • Click OK.

Step 4: Dynamically Change the Dropdown List using INDIRECT or OFFSET
  • In the same worksheet, select the cell below the dropdown list cell.
  • Go to the formula bar and enter the following formula: =OFFSET($B$2,MATCH($C$2,Cities,0)-1,0,COUNTIF(Cities,"*")).
  • The formula utilizes the MATCH function to find the position of the selected city in the "Cities" named range.
  • It then uses the OFFSET function to return the corresponding list of municipalities based on the selected city.
  • Adjust the cell references in the formula based on your specific data layout and range.

Now, whenever you select a city from the dropdown list, the list of municipalities will dynamically update based on your choice.

Remember to save your Excel file once you have completed these steps.
 
Solution

Similar threads

Back
Top