0
votes

I need to get the file name, not the sheet itself. I used the advice from

Is there a Google Sheets formula to put the name of the sheet into a cell?

but I need something else. please help!

enter image description here

2
Welcome. Include filename of source spreadsheet - in the question there is some code from yagisanatode.com for a custom function that will return the name of the file, or the name of the sheet or the names of all the sheets (depending on the argument supplied). This is what you want.Tedinoz

2 Answers

0
votes

You can use a Script to easily do it. I recommend you to take a look at the SpreadsheetApp documentation, specially at the setValue method from the Range Class and the getName method from DataSourceParameter.

The structure of the script could be:

 1. Get the active Spreadsheet
 2. Get the name 
 3. Set the value in an specified Range.
0
votes

Here is the code to input title of workbook to a particular cell.

function test(){
      var title=SpreadsheetApp.getActive().getName();//title of workbook
      var currentSheet=SpreadsheetApp.getActive().getSheetByName('Sheet2'); //sheet that you want to input the title
      currentSheet.getRange('A18:A18').setValue(title); //put title in cell A18 (You can change to other cells like B2 etc)  
}