通过单击将单元格值增加一 [英] Increment Cell value by one by clicking

查看:79
本文介绍了通过单击将单元格值增加一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Google表格中编写一个公式,以便我可以附加到按钮上,以使单元格中的值每次单击都增加1. 此处是我在该主题上能找到的最好的.

我试图这样做,但无济于事.我正在使用Windows 7和Chrome.

解决方案

首先创建一个脚本以增加单元格的值.例如,要将单元格"A1"加1,可以使用以下脚本:

function increment() {
  SpreadsheetApp.getActiveSheet().getRange('A1').setValue(SpreadsheetApp.getActiveSheet().getRange('A1').getValue() + 1);
}

保存此脚本并打开电子表格,然后按照以下步骤操作:

  • 转到插入">绘图",然后使用形状和文本绘制按钮.
  • 相应地定位您的按钮,然后右键单击它以显示一个 侧面的箭头.
  • 在下拉菜单中,选择分配脚本".并输入名称 您的功能. (在这种情况下为增量")
  • 第一次单击它会征求许可,但是 随后应该工作.

I want to write a formula in Google sheets so that I can attach to a button to make the value in a cell increase by 1 each time you click it. Here is the best I could find on this topic.

I attempted to do this, but to no avail. I am using Windows 7 and Chrome.

解决方案

First create a script to increment the cell value. For instance, to increment cell "A1" by one the following script would work:

function increment() {
  SpreadsheetApp.getActiveSheet().getRange('A1').setValue(SpreadsheetApp.getActiveSheet().getRange('A1').getValue() + 1);
}

Save this script and open your spreadsheet and follow these steps:

  • Go to "Insert" > "Drawing" and draw a button using shapes and text.
  • Position your button accordingly, and right-click on it to display an arrow on the side of it.
  • In the drop-down menu, select "Assign Script." and type the name of your function. (In this case "increment")
  • The first time when you click on it, it'll ask for permission but should work subsequently.

这篇关于通过单击将单元格值增加一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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