[英]How to fill a cell in a specific sheet with data of new Google spreadsheets
I have a sheet called "metrics" with one row for each day, for example:我有一张名为“metrics”的表格,每天一行,例如:
day counts1 counts2 counts3
01-01-2019
01-02-2019
01-03-2019
01-04-2019
01-05-2019
...
Each day I create a new sheet called the same as the date.每天我都会创建一个与日期相同的新工作表。 For example, in 01-06-2019 I create a sheet called "01-06-2019" and enter data into it.例如,在 01-06-2019 中,我创建了一个名为“01-06-2019”的工作表并在其中输入数据。 With this daily data, I calculate for each day counts1, counts2 and counts3.有了这个每日数据,我计算了每天的 counts1、counts2 和 counts3。
I want to fill the sheet "metrics" with those values adding a new row and the corresponding counts1, counts2, counts3.我想用这些值填充表格“指标”,添加一个新行和相应的计数 1、计数 2、计数 3。
Or, is it another better way to save the data and achieve this goal?或者,这是另一种保存数据并实现这一目标的更好方法吗?
={SUM( INDIRECT(TO_TEXT(A2)&"!B2:C2")),
AVERAGE(INDIRECT(TO_TEXT(A2)&"!C2:C")),
SUM( INDIRECT(TO_TEXT(A2)&"!B2:B"))}
function onOpen() {
SpreadsheetApp.getUi().createMenu('NEW DAY')
.addItem('Create New Tabs', 'createTabs')
.addToUi()
}
function createTabs() {
var ss = SpreadsheetApp.getActive()
ss.getSheetByName('metrics').getRange('A2:A').getValues().filter(String)
.forEach(function (sn) {
if (!ss.getSheetByName(sn[0])) {
ss.insertSheet(sn[0], ss.getSheets().length);
}
})
}
Plain text
并选择Plain text
this will automatically create new tabs from a list of dates in A column by skipping already created tabs/sheets and also skipping empty cells这将通过跳过已创建的标签/工作表并跳过空单元格从 A 列中的日期列表自动创建新标签
to avoid typing in dates each time, use this formula in A2 cell and drag down:为避免每次都输入日期,请在A2单元格中使用此公式并向下拖动:
=TO_TEXT(TEXT(DATE(2019, 1, 1)+ROW()-2, "MM-dd-yyyy"))
select Script editor选择脚本编辑器
copy paste the script复制粘贴脚本
save the project under some name以某个名称保存项目
click on run icon and authorise it...点击运行图标并授权...
select your account选择您的帐户
click on Advanced点击高级
select Go to * (unsafe)选择转到 *(不安全)
click on Allow and return to your sheet (you can close script window/tab)单击允许并返回到您的工作表(您可以关闭脚本窗口/选项卡)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.