Google Sheets filename in cell via formula instead of a script? - function

Is there a FORMULA that will display the name of the file in a cell?
I've found scripts that will do it, formulas that will display the sheet name, but no luck finding a formula that will show the filename.
If I have to resort to the script, so be it. But I'd like to use formula if possible.
If this has been asked before, please point me to the post and I will delete this one.

Related

Add space after comma between hyperlink addresses in Google sheets

Re: Google Sheets- Scripts
I am trying to write a script for Google Sheets that will add a space after the comma between imported URL's in the same cell. The imported URL addresses are located in column J starting in row 2. I would like this change to happen every time a new row is imported into the sheet. I realize it is proper etiquette to attempt to write the script the best I can. Unfortunately, I do not remember where to start. I have spent some time searching for an example that was close to what I was looking for, but I could not find one. I attached a pic of the sheet. Thank you in advance for your help.

Google apps script to add a link to every cell in a column

I'm super new to writing apps script. I'm trying to find code/way to add a link to every cell in a column in a google sheet preferably that incorporates the cell address (c2, c3, c4 etc) rather than doing it manually. I then want to use that URL to take the user from another tab/sheet in the document to that cell.
Thanks for any guidance/direction you can give me to find the answer to this or increase my knowledge so I can find the answer.

Google sheets Named ranges not consistent between sheets

I have two similar spreadsheets that share code in an apps script library.
I use named ranges to access the sheets from the code.
In one spreadsheet the ranges are sheetname!range like this:
and the other spreadsheet just uses range:
I have tried copying both spreadsheets and tried recreating ranges to match the other format but nothing seems to work. I have looked for something that tells me that the spreadsheets are different versions but cant find anything that is different. I can make the code look for either format but.....
If you copy a worksheet in a spreadsheet with a Named Range, then Google Sheets has to do something, as you can't have two Named Ranges with the same name in the same spreadsheet. What it does is create new Ranges with worksheet-level scope of the form: newworksheet!existingnamedrange. So I think that probably explains how you got to where you are.
In terms of fixing it? You can just delete the newworksheet!existingnamedrange name and recreate existingnamedrange. As you can have the same name in different spreadsheets. Or am I misunderstanding the problem?

Google Script Insert Formula to Non-Consecutive Cells

I've been searching for a solution for a while and have not been able to get one. I am new to Google apps script and appreciate any help with this newbie question.
Here is what I have:
spreadsheet.getRangeList(['I5', 'I10', 'I15', 'I20']).setFormula('=SUMIFS(Sheet1!$EZ:$EZ,Sheet1!$BV:$BV,"Criteria",Sheet 1!$L:$L,$A5)');
The problem is it will paste that formula to each of the cells without changing the $A5 to $A10, $A15 and $A20, respectively.
Is it possible to do what I am asking?
Instead of using setFormula use setFormulaR1C1
Related
How do I add formulas to Google Spreadsheet using Google Apps Script?

Google Scripts Generated VLOOKUP Formula Does not Calculate Properly

I am writing formulas to cells programmatically.
The following line of code:
formulaCells.setFormulaR1C1('=iferror(VLOOKUP(R[0]C[3],AutoCat!A:B,2,FALSE),"Requires Category")');
Adequately writes this formula into all the cells in the target Google Sheets file represented by formulaCells
=iferror(VLOOKUP(D2,AutoCat!A:B,2,FALSE),"Requires Category")
But the problem is that the formula defaults to the error flag "Requires Category" when it is written by Google Scripts, but if I write the very same formula manually into Google Sheets, the actual item identified by the VLOOKUP results.
This is so frustrating!
If I hover over the Google Script generated formula, the true solution from the VLOOKUP even appears in the flyover, but for some reason, does not appear in the cell.
Please help! Why will a Google Scripts generated formula not calculate properly wen the same formula entered manually will?
OK, after thinking I'd exhausted my mental resources on this, I tried one last thing, and it actually worked.
For some unknown reason, though the formula is accurate, Google Scripts generated formulas do not play well with a VLOOKUP which searches an unlimited range for a solution. So even though the VLOOKUP was finding the correct solution, it was not displaying it as the formula result.
I fixed this by creating in the Google Sheets file a named range of the data the VLOOKUP would search called AutoCategory, and then inserted that named range into the Google Scripts generated formula, and BOOM! the formula started working.
Here is the final code in Scripts:
formulaCells.setFormulaR1C1('=iferror(VLOOKUP(R[0]C[3],AutoCategory,2,FALSE),"Requires Category")');
And here is the final formula which is generated in Google Sheets:
=iferror(VLOOKUP(D2,AutoCategory,2,FALSE),"Requires Category")
setFormulaR1C1 requires R1C1 notation, which you provided with R[0]C[3], but AutoCat!A:B is A1 notation.
You could switch to setFormula() and pass in only A1 notation, but I think that using named ranges is a very good practice when combined with Google Apps Script.