Google sheet App script copy paste if clause - google-apps-script

I am not familiar with Google Scripts.
I have a function =weeknum(today() in cell A1 (constantly updating when weeks change).
Then I have weeks running from 1-52 in cells A3:A54 and formulas in cells C3:F54.
I would like to have a script which copy pastes values for last weeks formula rows every time week changes.
e.g. when week 4 changes to week 5 (A1), formulas in C6:F6 (week 4 rows) (or C3:F6 week 1-4 rows) (prior week or all prior weeks) are replaced automatically with copy pasted values, so I get the prior weeks numbers stored.
Thanks

Related

Creating an automatic and self-generating weekday data entry sheet in google sheets

In short, I need admins at my work to be able to punch in whether someone is on leave or not into a sheet that informs other sheets to create daily staffing lineups all based in Google Sheets. Right now, I have them deleting whole columns of values and keeping track of what day it is every day. Obviously this is open to error and is a task I'd like to eliminate.
Essentially, I have 7 cell-wide table with the first one being =today() and each one in that row being =today()+1 through =today()+6. What I want to see happen is for the values (underneath) that correspond to that day move (to the left) as the date updates. Furthermore, icing on the cake, I need the new =today()+6 to automatically generate with "no" in each cell under that newly generated date (column H in the below example).
For example, in my submitted sheet, today Karen is OFF in column B. However, in two days time she'll be on VAC which, by that time, should be column B.
I appreciate any help.
Schedule
Here's a link to the sample sheet
Your task can be done if you change the way your managers enter data. If they fill out the data in a table like this
then your master table would look like this
you need to clear the contents in the range B5:H9 and copy the following formula into cell B5
=ArrayFormula(IFNA(VLOOKUP(TRUE&TRUE&$A5:$A,{(Sheet2! $A:$A<=B3)&(Sheet2!$B:$B>=B3)&Sheet2!$C:$C,Sheet2!$D:$D},2,FALSE), "no"))
Then you need to extend this formula to cell B9

Automatic Average For X Most Recent Column Entries

I have a sheet where someone enters numbers into a column every week
Is there a way to have a column that automatically shows the average of the x most recent weeks entered?
So when a new week is entered, the average formula automatically changes the range of columns used for that average
Or possibly via script if needed?
e.g. After the user fills in the new week, I could have them run a script in the sheet to recalculate the average.
Any hints are appreciated.
Not sure how to word a search to look for examples.
And the winner seems to be AVERAGE & OFFSET
This gives me the average for the last 5 entries in the 2nd row
=AVERAGE(OFFSET(C2,0,COUNT(C2:AQ2)-5,1,5))

Time Trigger Copy Paste

I'm fairly new to Google scripts and so far I only have a functional understanding of 'onEdit'. I want to incorporate Google's time triggers however I don't know how to do it due to lack of understanding.
Here is what I am trying to do:
Objective: Create a spreadsheet that keeps track of metrics on a weekly basis
Current Set up: Currently, the spreadsheet uses 'CountIF' on a queried spreadsheet from multiple users to compile all the data and determine the status of every to-do item at any moment.
Need: I would like to set up a script that takes affect every Sunday. The script would copy the metrics from the previous week and paste them into a row below based upon the start date and date date of the previous week (Which are kept in columns A ad B...Ex: 7/7/2018 & 7/14/2018. If the previous week falls into this date range, the cumulative metrics for that week will paste into columns C-L of that week.
Essentially, row 3 would always keep the running total and then the rows below row 3 would populate with a "total to date" for the given date range.
In your Apps Script editor go to Edit > Current Projects Triggers and select Time Driven > Week Timer.

How to retrieve time of last edit

I have a Google Sheets that updates automatically throughout every day but sometimes gets stopped up. I want to store and update the time and date of the last time any cell in the first column is changed in a single cell.
For example:
1. I open a sheet.
2. The sheet automatically pulls and updates a .csv file from a server.
3. The cells are regenerated and updated.
4. When any cell in the first column is changed
5. Update the time of the last edit in a cell of another sheet.
I use this :
DocsList.getFileById("myID_Spreadsheet").getLastUpdated()

Carrying a sum forward as new spreadsheet is created

I have a google spreadsheet that I am trying to manipulate data on. I have a Master spreadsheet, and once a week, it is duplicated and renamed, by the week. An example of this would be Sept 8-12 2014 and then the next would be Sept 13-21 2014. I have the sheet set to do a sum of each row, and put the total in the second last column. In the last column, I would like to do a grand running total for the year.
So, if for example my column that totalled everything was AC, and the last one was AD, is there a way that I can set my spreadsheet to pull the data from AD of the last sheet, and then continuing summing up the total on the new current sheet after the Master spreadsheet is duplicated and renamed each week?
Thank you,
Paul
Yes, you can reference data from other sheets. You may have to change what sheet it references every time you duplicate though.
Alternatively, with appscript, you can use the getSheets() method to get every sheet. Then you can pull whatever necessary cell data from each sheet.