This question already exists:
Is there a custom function or script that returns gid of a specific sheet in Google Sheets?
Closed 1 year ago.
Important: I asked this question before and it was merged into another question where the solution is using a script. Such a solution, with a script, is not helpful to me, so please only offer a solution with formulas, thanks.
I have a main sheet with a list of the names of the other sheets in the workbook. I want to create a glossary in the main sheet linking to cell A1 in each of the other sheets (a simple Hyperlink).
In Col A - list of sheet names (e.g. Jan, Feb)
In Col B - I want the hyperlinks (e.g. a link to Jan!A1, a link to Feb!A1)
What I can do, is use INDIRECT and CONCATENATE to bring the respective value of the cells (I've added it in Col C in the example below), but I can't find how to create the links.
Here's an example:
https://docs.google.com/spreadsheets/d/1C1LghRPcutYBwgZZaitJQ1PVrgggr5XdvG6V7L32eE0/edit#gid=0
and here we go again... this is your previous question: stackoverflow.com/questions/70054228 (for reference)
what you don't need is:
INDIRECT formula
CONCATENATE formula
because these are not capable of solving your issue
to solve your question:
Hyperlinking to sheets without using a script
you need two things:
HYPERLINK formula
#gid= number
GID number can be acquired from the URL of every sheet tab. for creating a list of all GID numbers you need a script. since the script is not an option for you (as for your request), your only option is to create a list of GIDs manually - eg. going into each tab of your spreadsheet and extracting GID numbers from the URL
note: each spreadsheet has unique GID numbers for each of the sheets. only first sheet on every spreadsheet has GID value set to 0 - #gid=0
after you will have all the necessary GIDs (let's say in a column) you can go for the next step and use HYPERLINK formula:
instead of the URL as the first argument, we use GID to create jump links:
=HYPERLINK("#gid=1220119768"; "Sheet 2")
of course, this is the same as using full URL:
=HYPERLINK("https://docs.google.com/spreadsheets/d/1yaRwbLGmDeynYktvxmLJcCBZrAvqgJA-_nYTlVf92Tc/edit#gid=1062970060"; "Sheet 2")
the only difference is in formula length
for multiple hyperlinks we can use arrayformula:
=ARRAYFORMULA(HYPERLINK("#gid="&A2:A5; B2:B5))
where:
A B
1
2 1062970060 Sheet 2
3 2118975038 Sheet 3
4 273293449 Feb
5 1564587416 some other label
6
if you want your hyperlinks to lead for example to F8 you can add &range=F8 so:
=ARRAYFORMULA(HYPERLINK("#gid=" & A2:A5 & "&range=F8"; B2:B5))
also, if it wasn't clear... labels are not mandatory. you can skip them and have just:
=HYPERLINK("#gid=1220119768")
and also keep in mind that the 2nd argument of HYPERLINK can take even formula:
=HYPERLINK("#gid=1220119768"; INDIRECT(A2&"!A1"))
and to save your time... INDIRECT is not supported under ARRAYFORMULA. the only workaround for that would be to place multiple INDIRECTs into array {}:
=ARRAYFORMULA(HYPERLINK("#gid="&
{"1220119768"; "2118975038"; "273293449"; "1564587416"};
{INDIRECT(A2&"!A1"); INDIRECT(A3&"!A1"); INDIRECT(A4&"!A1"); INDIRECT(A5&"!A1")}))
Related
I have 2 documents:
Document 1 contains a list with so called Set-names, displayed as "Set". And within each "Set" there is name that can be found that corresponds to the number within that set.
Document 2 contains all the Set-names with each their own numbers and Name. Each Set-name has it's own Sheet, and there is a lot of them.
I want to fill in just the Set-name "Set" and Set-number "Set#", to automatically display the name corresponding to these two values. The question is however, how do I do that?
Document 1: Collection
Shared document link: Click here (File > Make copy)
Document 2: All Set-names
Shared document link: Click here (File > Make copy)
In this example above I would like to output "Dark Raichu" within Document 1 at Q74:T74 and at Q75:T75. Is this even possible to make? INDIRECT might help as well so I don't have to manually edit each Set-name. Any idea/suggestion/solution is much appreciated!
EDIT
(following OP's explanations)
First of all I have to say that you should AVOID making such radical changes to the original question, since it completely throws readers off balance.
Having said that there is a completely different approach that should be followed.
In your Document 2: All Set-names
Step 1
Go to your Wizards Black Star Promos tab.
Using a formula like =ArrayFormula(A4:A59&"/555")
change the Set # from 1,2,3...59 to 1/555,2/555,3/555...59/555
(555 can be any unique number that does NOT conflict with the other sets)
Step 2
Create a new tab. Name this tab AllSets
Step 3
Use this formula in cell A2
={FILTER('Base Set'!A5:C,'Base Set'!A5:A<>"");
FILTER(Fossil!A5:C,Fossil!A5:A<>"");
FILTER('Base Set 2'!A5:C,'Base Set 2'!A5:A<>"");
FILTER('Wizards Black Star Promos'!A5:C,'Wizards Black Star Promos'!A5:A<>"");
FILTER(Jungle!A5:C,Jungle!A5:A<>"")}
Using this pattern complete the formula for the rest of your tabs. You will end up with a 3 columns list of all your sets in one place.
In your Document 1: Collection
Step 4
Go to your Collection tab.
In cell Q2 (where column Q is exactly before your Name column R) use the following formula.
(As before, complete the formula for the rest of your tabs)
=INDEX(IFERROR(N2:N&(SWITCH(H2:H,
"Base Set","/96",
"Jungle","/64",
"Wizards Black Star Promos","/555",
"Fossil","/62"))))
This way you will bring the complete Set # back.
This will be our helper column which can be hidden and will be only used in the next formula.
Step 5
In the same Collection tab and in cell R2 place this formula
=ArrayFormula(IFERROR(
VLOOKUP(Q2:Q,IMPORTRANGE("1n8iWAl7ZQhsue6Opefvh_9yDwMk06PvqUdQoVuEJw00","AllSets!A2:C"),{2,3},0)))
The above final formula will give you everything.
The Card name, the Type as well as the Link and the Image of the card.
If you do not want the Type just change this part of the formula {2,3} to just 2.
Step 6
Enjoy :)
Additional functions used:
FILTER
INDEX
SWITCH
Original answer
(For the question as originally posted )
You can use a combination formula like
=ArrayFormula(IFERROR(
VLOOKUP(V2:V,{REGEXEXTRACT(Sheet1!R2:R,"\d+")*1,Sheet1!S2:S},2,0)))
(do adjust ranges and locale syntax to meet your needs)
Functions used:
ArrayFormula
IFERROR
VLOOKUP
REGEXEXTRACT
You can easily import a range from one Spreadsheet to another using IMPORTRANGE. IN your case described as you wanted to import the range A5:A (i.e all cells in column A minus the first 5 cells in the column) of the sheet Team Rocket of the Spreadsheet Document 2 into Document 1 cell Q73 you would need to use this function in cell Q73:
=IMPORTRANGE("YOUR DOCUMENT 2 SPREADSHEET URL","Team Rocket!A5:A")
Note that when you first use this function it might ask you to grant access between these Spreadsheeets to let one get the data from the other
I have 2 sheets which are connected.
Sheet-1: Has ID column and Status column (Status field is manually updated by the team)
Sheet-2: Has ID column and Status column (+ many other fields)
Requirement: Status column in Sheet 2 to be updated from Sheet-1 if ID column in sheet-2 = ID column in Sheet-1
I wrote a Query and ImportRange, but I could find Query working only when I compare it against a static value (for e.g. Yes). What I want is it to check against the value in ID column from both the sheets and import only for rows that match.
=QUERY(IMPORTRANGE("1ZkPaYb1IIIkcbVerdmZ-Ru1vxFu1YMWj74QNQj2jles", "Ops Action Sheet!B2:B10000"),"select Col2 where Col1 = 'Yes'")
This doesn't directly answer your question about using QUERY, but I believe that that function might not be the best tool for what you're trying to do.
I write below a solution using the alternative function VLOOKUP.
I am assuming here that by "Sheet-1" and "Sheet-2", you actually mean entirely different spreadsheets, judging by your use of IMPORTRANGE.
If you don't mind having a copy of Sheet-1's contents living within Sheet-2, here is what you can do:
On a new sheet (tab) in Sheet-2, copy this function (fill in sheet_1_url):
=IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B")
You should see a copy of the data from Sheet-1 in that tab. You can hide this tab or protect it if you wish.
On your main data tab within Sheet-2, copy this formula in your Status column (assuming that your ID is in A2:
=IFERROR(VLOOKUP($A2,range_from_step_1,2,),)
Copy that formula down as much as you need.
However, if you don't want to have a copy of Sheet-1's data in Sheet-2 for whatever reason, you can simply skip steps 1-2 above, going straight to step 3, with the following formula in Sheet-2:
=IFERROR(VLOOKUP($A2,IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B"),2,),)
Not that I recommend it, since you'd technically be importing your data virtually within the formula N number of times, which will be a huge performance hit.
You can see the references for the formulas used above here:
IMPORTRANGE
VLOOKUP
IFERROR
edit to reflect and paste in spreadsheet 2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, IMPORTRANGE("ID", "Sheet!A:C"), {2, 3}, 0)))
A2:A - column of IDs in spreadsheet 2
Sheet!A:C - column A of this range hosts IDs
{2, 3} - brings column B and C from spreadsheet 1 into spreadsheet 2
I'm looking for a way to add together a dynamically generated list of ranges using (I'm guessing) an ARRAYFORMULA.
The normal way of attacking this is fine if there is a known list of ranges, the example of the results I want would work using this:
=ARRAYFORMULA( A1:A10 + B1:B10 )
In the case I'm after I want to add together ranges in multiple sheets. I don't want the users to have to manually adjust the array formula every time they add a new sheet to be calculated, and I also want to be able to add some logic to include or remove the particular sheet from the calculation, but for now I'm happy to ignore that and just focus on adding cells together.
My approach to this was to create a column with a list of names, each one matching a sheet in the document, and then using that list to dynamically build the list of ranges to add together, using INDIRECT.
.------------.
| sheet1 | <---- SheetListNamedRange
|------------|
| sheet2 |
`------------'
Here's a quick example
=ARRAYFORMULA( INDIRECT("'" & SheetListNamedRange & "'!D4:75") )
There are lots of failure modes depending on how it's done, but this particular formula only puts in the values of the first sheet and ignores any others, which I guess makes sense.
What I'm after is kind of the equivalent of i++ in a loop found in a normal coding language. Is there some way of making this work?
If I understand you correctly, you'd like to get a list generated based on different ranges across different sheets. If your case is as simple as the one you mention in the beginning of your post, the following would do the job.
={Sheet1!A1:A2; Sheet2!B1:B2}
If you want the sum of all these values, you can use SUM.
=SUM({Sheet1!A1:A2; Sheet2!B1:B2})
Please let me know if this isn't what you were looking for, so I can change the answer accordingly.
you can't refer to array of arrays in INDIRECT. you will need to INDIRECT each sheet which contains array.
=SUMPRODUCT(ARRAYFORMULA(INDIRECT(A1&"!"&"D:D")+
INDIRECT(A2&"!"&"D:D")+
INDIRECT(A3&"!"&"D:D")+
INDIRECT(A4&"!"&"D:D")))
note1: in this case result is 25 as sum of 10 + 15.
10 is sum of sheet1!D:D
and 15 is sum of sheet2!D:D
note2: there is no sheet3 and sheet4 which is equal to 0 in INDIRECT
note3: D:D of the sheet where you have the list of sheets needs to be empty
I have 2 google workbooks. One is a rate sheet and the other is a vendor list with pricing.
I have the vendor list with pricing workbook linked to the rate sheet workbook via importrage command. This works great and everything updates as it should until you add a new line or remove a line to the rate sheet workbook. At this point the vendor workbook does not update the reference and just still points at the same lines it was originally, now displaying the incorrect data.
How can I dynamically have the vendor list workbook notice the addition or removal of lines in the rate sheet workbook and update the importrange formula?
Can this be done?
Any help is greatly appreciated.
EDIT: I have prepared 2 sample workbooks. They are Test sheet 1 - Rates and Test Sheet 2 Lanes
I have all of our rates in the first sheet. In the second we would have vendor lanes. This sheet consists of multie tabs all with an individual lane that is linked to 1 row in the rates sheet.
In the lanes sheet I have linked the two together via importrange in cell A8. Now this works and links properly, that is until you insert a new line in the rates sheet above the one the lane is linked to and then it doesn't update but shows what the new line information is.
Is there a way to have the lanes sheet dynamically update to the next line when a new line is inserted in the rates sheet?
two sheets links are as follows:
Rates
Lanes
Solution 1 - if you need to check only one condition
To achieve desired result you have to have something like an ID for every rate. For sake of this answer (based on your example sheets) I assume that this could be an Origin City. In Test Sheet 2 I have added new sheet - SheetTest where:
First step
I am looking for the row number where desire City reside in Rates sheet (in example - its Mcclellan city). The code for that is simple:
MATCH(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q/edit","Rates!B:B"),0).
This gives me -> 10
Second step
I use this result to dynamically generate final range - "Rates!A10:X10". The final result in A8 cell is (to make it clearer, I change an address of a sheet to -othersheeturl- :
=IMPORTRANGE(
"-othersheeturl-",
"Rates!A"&
MATCH(A2,IMPORTRANGE(-othersheeturl-","Rates!B:B"),0)
&":X"&
MATCH(A2,IMPORTRANGE("-othersheeturl-","Rates!B:B"),0)
)
Working example
Warning
I see that in your original sheet you use "take" Origin City from Rates sheet, so I remove this dependency in A2 to make it an ID. I hope this solves your problem.
Solution 2 - if you need to check many conditions
An approach is the same, but tools are different. Main goal is to find a row number that meets criteria - "From City" and "To City". Then this row number will be used to concatenate desire range.
First step - some cleaning
To better manage complex formulas its a good idea to divide them into smaller pieces - like in "ordinary" programing. So, we have:
From City in A5
New Albany
To City in B5
Calgary
Rate sheet (external sheet) url in B1:
1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q
You don't have to put whole URL, only this part is needed
Formula that counts row number that we are looking for in B2
=QUERY(
{IMPORTRANGE(B1,"A1:B"),
ArrayFormula(row(INDIRECT("A1:A"&ROWS(IMPORTRANGE(B1,"A1:B")))))},
"select Col3 where Col1='"&B5&"' and Col2='"&A5&"'
limit 1")
Above code:
Build an array from Rate sheet (external) - columns A1:B and virtual index that represents rows numbers
Then, show only column nr 3 (index) where Col1 matches our "To City" and Col2 matches "From City"
At the end is a limit to only one result (in case that there are more then one maches)
Desire range in B3
="Rates!A"&B2&":X"&B2
Final formula that renders desire data from external sheet in A11
=IMPORTRANGE(B1,B3)
Working example
Final thoughts
You can either hide rows 1-3 or you can pack all above formulas into one. Its up to you. I prefer the first approach.
This solution gives you freedom with as many conditions as you want
More info would be helpful.
A couple ideas:
Using named ranges instead of a static reference. For example, if you create a named range in the rate sheet called MY_DATA that references A2!C600, you can include "MY_DATA" in your importrange in the vendor sheet. Note that you'd still need to update MY_DATA every time you add a row.
If you're importing the entire sheet, perhaps omitting the end row would work (e.g. A2!C instead of A2!C600) - note that this means you need to use filter or query in the Vendor sheet to eliminate the blank rows.
This question already has answers here:
How to maintain absolute cell address even when deleting ranges?
(2 answers)
Closed 5 months ago.
So I have an google spreadsheet, I am build a cache stats page, that just caches other sheets in the document. All the other sheets are constantly changing.
Here is an example.
I have 2 sheets in a workbook.
SheetA and SheetB
SheetA has 1 column 1 row. A1 and in A1 we have a value of lets say $50.00
SheetB has the same thing, 1 row 1 column. A1 has a formula of ='SheetA'!$A$1
If I go into SheetA and add a column to the left of A1, Google Spreadsheet updates my formula to be ='SheetA'!$B$1
I was under the impression with the $ (dollar) sign the reference should not change but it does. Any ideas on how to prevent Google from updating my formulas? Currently anytime I update the sheets I have to run a script to update all the formulas back to the original.
Try wrapping that in an indirect function. That should prevent the 'shifting'.
=INDIRECT("'SheetA'!A1")