gpt4 book ai didi

How to add a tickbox if next cell is not blank (must be a function)(如果下一个单元格不为空(必须是函数),如何添加勾选框)

转载 作者:bug小助手 更新时间:2023-10-24 18:45:58 25 4
gpt4 key购买 nike



Edit: My second script actually works, it just doesn't recognize a zero "0" as being data so it sees a blank instead.
After changing it from "B" to "C" which contains words instead of numbers the script works every time.

Should I remove this question? @mods

编辑:我的第二个脚本实际上起作用了,只是它没有将零“0”识别为数据,所以它看到的是一个空白。将其从“B”更改为“C”后,脚本每次都能正常工作。我应该删除这个问题吗?@MODS


I've created a script that will add a checkbox in A1 if B1 is not empty.
For some reason it only works on row 1 when I run it, and I want it to execute for the whole sheet from A2:A100.

我已经创建了一个脚本,如果B1不为空,该脚本将在A1中添加一个复选框。由于某种原因,当我运行它时,它只在第1行起作用,并且我希望它在A2:A100的整个工作表上执行。


I tried this first:

我先试了一下:



function addTickboxToColumnA() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getRange("A:B").getValues();
for (var i = 0; i < data.length; i++) {
if (data[i][1] != "") {
sheet.getRange('A' + (i + 1)).insertCheckboxes();
}
}
}

Then this

然后就是这个


function addTickbox() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lastRow = sheet.getLastRow();
var range = sheet.getRange('A1:A'+lastRow);
var values = range.getValues();

for(var i=0; i<values.length; i++) {
if(sheet.getRange('B'+(i+1)).getValue() != '') {
sheet.getRange('A'+(i+1)).insertCheckboxes();
}
}
}

Thanks for any help. I've searched and found a lot of answers that suggest using conditional formating to hide tickboxes, but this won't work for me as I use a lot of "getlastrow" so filling column a with hiden or white tickboxes is no bueno.

谢谢你的帮助。我已经搜索并找到了很多建议使用条件格式来隐藏勾选框的答案,但这对我不起作用,因为我使用了很多“getlastrow”,所以用隐藏的或白色的勾选框填充a栏是行不通的。


更多回答
优秀答案推荐
更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com