Search code examples
google-sheetsgoogle-sheets-formula

Automatically transfer data from the same cell in different sheet tabs to one table


I'm currently attempting to make an invoice template with a built in log that will allow me to just duplicate a template tab, rename to invoice number and then output the total owed to a logs tab to keep track of what i am owed and when i received the check.

Currently, the setup has it, so the total is always in Cell D21, but it'd be cool to just store the total to a value and output it to the log so it didn't always read the same cell.

I'm currently having to manually go through and put ='tab name'!D21 in each tab of the rows which is annoying. I tried dragging down to each other row but it only adds 1 to the cell number rather than the sheet name (in hindsight this was obvious) is there a way for me to solve this?


Solution

  • You can input the sheet names into one column in your logs tab, say column A: Invoice 1, Invoice 2, etc. and then you can use the INDIRECT() function to turn the strings/values in column A (Invoice 1, Invoice 2, etc.) into a variable.

    Since your data in each sheet is following a template, you'd easily be able to ctrl+d down the same cell value, but for different sheet names.

    For example, if your values were in cell B2 in sheet "Invoice1" and sheet "invoice2":

     Column A     Column B
     Invoice1     =INDIRECT(A1&"!$B$2")
     Invoice2     =INDIRECT(A2&"!$B$2")
    

    For a more customizable approach I would recommend reading into Apps Script

    Reference Material: