如何在每天结束时记录Google表格单元格的内容? [英] How can I record the contents of a Google Sheets cell at the end of each day?

查看:293
本文介绍了如何在每天结束时记录Google表格单元格的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google表格中,我使用IMPORTHTML函数动态地收集数据,并且该数据集中的一个元素当前已复制到单元格C1中。



在另一个工作表I有一个从现在到2017年的日期列表A列。



在每天结束时,我想记录最后的C1分数在B列旁边相关日期。



我会如何以自动方式执行此操作?也就是说,我希望电子表格能够在每天结束时自行完成。 您需要一个脚本来复制条目from sheet1!C1 into sheet2!columnB row(where columnA = today())。



将sheet1,sheet2替换为表名。



设置电子表格



在您的电子表格中转到



文件>电子表格设置



设置您的本地和时区,然后设置重新计算onChange和每小时。



使用内置函数查找今天的行



goto sheet2!



我假设您的columnA具有日期格式从A1到A#的日期。
我们将需要一个单元来保存一个值,我选择C1。
in C1把这个



= MATCH(today(),A:A)

会给你一个数字,它应该是持有今天日期的行。



建立脚本



然后转到

工具>脚本编辑器



为电子表格创建脚本。这将给你一些示例脚本,删除它。



代码是

  function scorekeeper(){
var sheet1 = SpreadsheetApp.getActiveSpreadsheet()。getSheetByName(sheet1);
var sheet2 = SpreadsheetApp.getActiveSpreadsheet()。getSheetByName(sheet2);
var score = sheet1.getRange(C1)。getValue(); //我们想存储这个
var row = sheet2.getRange(C1)。getValue(); //这是我们的行
sheet2.getRange(row,2).setValue(score);
}

您可以通过执行Run并选择函数名称来测试。您可能必须先保存脚本并给予应用权限。



设置触发器



让我们来做这个在午夜运行



转到



资源>当前项目的触发器。

添加一个触发器。



选择;
记分员()
时间驱动的
日间定时器
午夜到凌晨1:00

你很好去。


In Google Sheets I'm collecting data dynamically using the IMPORTHTML function, and one element from that data set is currently copied in cell C1.

In another sheet I have a list of dates from now until 2017 as column A.

At the end of each day, I'd like to record the final C1 score in column B next to the relevant date.

How would I go about doing that in an automated way? That is, I want the spreadsheet to complete itself at the end of each day.

解决方案

You need a script that copies the entry from sheet1!C1 into sheet2!columnB row(where columnA=today()).

Replace sheet1, sheet2 with your sheet names.

Setup spreadsheet

Within your spreadsheet goto

File>spreadsheet settings

Set your local and time zone, then set the recalculation onChange and every hour.

Use inbuilt function to locate today's row

goto sheet2!

I am assuming your columnA has the dates running from A1 to A# in date format. We are going to need a cell to hold a value, I am choosing C1. in C1 put this

=MATCH(today(),A:A)

This will give you a number, it should be the row holding today's date.

Build the script

Then goto

tools>script editor

create a script for spreadsheets. This will give you some sample script, delete this.

code is

function scorekeeper(){
  var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("sheet1");
  var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("sheet2");
  var score = sheet1.getRange("C1").getValue(); // we want to store this
  var row   = sheet2.getRange("C1").getValue(); // this is our row
sheet2.getRange(row, 2).setValue(score );
}

You can test this by going to Run and selecting the function name. You may have to save the script first and give the app permission.

Setting the trigger

Let's make this run at midnight

goto

Resources>Current project's triggers.

Add a trigger.

Select; scorekeeper() Time-driven Day timer Midnight to 1:00 a.m.

And you are good to go.

这篇关于如何在每天结束时记录Google表格单元格的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆