Nov 16 2023 03:21 PM
I have an Excel 2021 spreadsheet with multiple tabs (for multiple locations/cities). Each tab has similar data. One column has a list of various fruits/fruit trees and the second column has the quantities of each fruit at that location. There are 4 locations/cities so 4 tabs and a 5th tab for summary purposes that uses the Xlookup function to look at a selected tab to find the correct row for the fruit and pull the quantity. I've created a dropdown list of the 4 locations using the tab names. I want to be able to change dynamically which tab the quantities are pulled from based on which location I select from the dropdown tab. Can anybody explain to me how to do that? Any help would be appreciated.
Nov 16 2023 10:42 PM
SolutionYou can achieve this by using the INDIRECT function in combination with your XLOOKUP formula. The INDIRECT function allows you to create a reference to a cell specified by a text string, and you can use this to dynamically refer to the selected tab.
Assuming you have a dropdown list of locations in cell A1 on your summary tab, and your tabs are named after the locations, you can modify your XLOOKUP formula like this:
=XLOOKUP("Apple", INDIRECT("'" & A1 & "'!$A$2:$A$100"), INDIRECT("'" & A1 & "'!$B$2:$B$100"), "Not Found")
Explanation:
Adjust the formula according to your actual cell ranges and data structure. This way, when you change the location in the dropdown list (cell A1), the XLOOKUP formula will dynamically refer to the corresponding tab for the data lookup.
Make sure the dropdown list in cell A1 contains the exact names of your tabs so that it matches the tab names. The text was created with the help of AI.
Formularbeginn
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.
Nov 17 2023 01:24 AM
@Bill_Miller Unless you have a compelling reason to collect and keep data in separate tabs for each location, I would recommend to combine all in one table and add a column holding the location. Then you can use slicers for the location and the fruit without the need for a dropdown list and the use of INDIRECT.
The attached workbook contains a crude model of what I mean.
Nov 18 2023 05:59 PM
@NikolinoDEThanks for the suggestion and the guidance on how the syntax should be set up. I apologize for the delay in getting back to you. I'm not familiar with the INDIRECT function so I'll have to give it a try and let you know how it works. In the meantime, I appreciate your response.
Nov 18 2023 06:01 PM
Nov 22 2023 12:55 PM
Nov 16 2023 10:42 PM
SolutionYou can achieve this by using the INDIRECT function in combination with your XLOOKUP formula. The INDIRECT function allows you to create a reference to a cell specified by a text string, and you can use this to dynamically refer to the selected tab.
Assuming you have a dropdown list of locations in cell A1 on your summary tab, and your tabs are named after the locations, you can modify your XLOOKUP formula like this:
=XLOOKUP("Apple", INDIRECT("'" & A1 & "'!$A$2:$A$100"), INDIRECT("'" & A1 & "'!$B$2:$B$100"), "Not Found")
Explanation:
Adjust the formula according to your actual cell ranges and data structure. This way, when you change the location in the dropdown list (cell A1), the XLOOKUP formula will dynamically refer to the corresponding tab for the data lookup.
Make sure the dropdown list in cell A1 contains the exact names of your tabs so that it matches the tab names. The text was created with the help of AI.
Formularbeginn
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.