Google apps script 当不包含'#';
因此,我试图编写一个脚本,在编辑时检查单元格是否包含“#”,如果没有,则清除单元格。我有它的大部分工作,除了它似乎有时会改变单元格格式时,值粘贴到单元格。我不能保证粘贴的格式是正确的,所以我尝试添加一种方式,使单元格格式处于编辑状态,然后检查“#”。这就是我到目前为止所做的:Google apps script 当不包含'#';,google-apps-script,google-sheets,Google Apps Script,Google Sheets,因此,我试图编写一个脚本,在编辑时检查单元格是否包含“#”,如果没有,则清除单元格。我有它的大部分工作,除了它似乎有时会改变单元格格式时,值粘贴到单元格。我不能保证粘贴的格式是正确的,所以我尝试添加一种方式,使单元格格式处于编辑状态,然后检查“#”。这就是我到目前为止所做的: 函数onEdit(e){ var sheet=SpreadsheetApp.getActive().getSheetByName('CAHT'); var lr=sheet.getLastRow() var VAL=she
函数onEdit(e){
var sheet=SpreadsheetApp.getActive().getSheetByName('CAHT');
var lr=sheet.getLastRow()
var VAL=sheet.getRange(2,6,lr,1).getValues()
var newVals=[]//仅新的数字数组,其中文本为空。
对于(i=0;i这就是我们想要的吗
function onEdit(e){
//e.source.toast('Entry');
var sh=e.range.getSheet();
if(sh.getName()!='CAHT')return;
if(e.range.columnStart==6 && e.range.rowStart>1) {
//e.source.toast('Past Return');
var vA=sh.getRange(2,6,sh.getLastRow()-1,1).getValues();
var newVals=[];
for(var i=0;i<vA.length;i++){
if(typeof vA[i][0]=="number"){
//e.source.toast('number');
newVals.push([vA[i][0]])
}else{
//e.source.toast('not number');
newVals.push([null]);
}
}
sh.getRange(2,6,newVals.length,1).setValues(newVals);
e.source.toast(newVals.map(function(r){return r[0]}).join(),'newVals',-1);
}
}
函数onEdit(e){
//e、 source.toast(“条目”);
var sh=e.range.getSheet();
if(sh.getName()!='CAHT')返回;
如果(e.range.columnStart==6&&e.range.rowStart>1){
//e、 来源:toast(“过去的回报”);
var vA=sh.getRange(2,6,sh.getLastRow()-1,1).getValues();
var-newVals=[];
对于(var i=0;ii如果现有答案不能解决您的问题,请详细解释您想要实现的目标。您所说的“#”是指字符#
,还是代表数字?