Home > front end >  Google Sheets App Script Add Value Cell Based on Date
Google Sheets App Script Add Value Cell Based on Date

Time:10-22

I have the following sample sheet which uses the following formulas that somewhat work. I say somewhat because often opening the sheet there are errors with the filter formulas after sorting filtering the tabs or sometimes when new rows are added. The values being set are not going to change once set initially so I'm looking for some help getting me started with an app script that will set the values on open if the value in the respective cells are blank.

I'd like to use app script one because of the said errors and also interested in learning it a bit. I've done a bit of js work in other platforms and confident I can dial this in with help with one or of the following

Transaction Tab

    FILTER(text(B2:B,"MMMM"),Not(ISBLANK(B2:B)))
    FILTER(text(B2:B,"YYYY"),Not(ISBLANK(B2:B)))
    filter(if(E2:E < 0,"debit","credit"),not(ISBLANK(E2:E)))
    filter(VLOOKUP(D2:D,Lists!A:B,2,false),not(ISBLANK(B2:B)))

BalanceHistory

   FILTER(text(B2:B,"MMMM"),Not(ISBLANK(B2:B)))
   FILTER(text(B2:B,"YYYY"),Not(ISBLANK(B2:B)))
   ARRAYFORMULA({"Date/Time"; B2:B C2:C})

enter image description here

(Update)

  • I updated the code to include the Group column value in Transactions sheet. I just read the values in your Lists sheet and create a JavaScript Object with column A (Category) as the key and column B (Group) as the value. Refer to listsMap variable on how it was created.
  • Then I used the current row's category in Transactions sheet to get its equivalent group value in the JavaScript Object.
  • Related