1
votes

So I have a Googlesheet with multiple tabs: Tab1, Tab2, Tab3, etc...

I will ask the user to select from a dropdown of the tab options.

How do I make a query that chooses the same data range but from the tab that the user chooses?

For example:

=query(Tab1!$A$1:$Z$100, "select A, B, group by A")

But if the user selects Tab2 in dropdown, then I want the query to automatically become:

=query(Tab2!$A$1:$Z$100, "select A, B, group by A")

Basically same everything except the data range is now coming from a different tab.

Thanks

1
group by cant be used without aggregation - player0

1 Answers

0
votes

you need to indirect it... let's say the dropdown is in A1 then your query will be:

=QUERY({INDIRECT(A1&"!A1:Z100")}, "select Col1,Col2")

where ofc tab/sheet name = A1 dropdown option