Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 修改代码-查找&;替换单元格中的文本Google应用程序脚本/Google工作表_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 修改代码-查找&;替换单元格中的文本Google应用程序脚本/Google工作表

Google apps script 修改代码-查找&;替换单元格中的文本Google应用程序脚本/Google工作表,google-apps-script,google-sheets,Google Apps Script,Google Sheets,如果单元格中只有AU5000,则下面的代码会按预期执行-但是我需要稍微修改。我的单元格包含类似于AU500014234的工作编号。我想脚本删除AU5000,留下剩下的5个数字,即14234 function fandr() { var ss=SpreadsheetApp.getActiveSpreadsheet(); var s=ss.getActiveSheet(); var r=s.getDataRange(); var vlst=r.getValues(); var i,j,a,find,

如果单元格中只有AU5000,则下面的代码会按预期执行-但是我需要稍微修改。我的单元格包含类似于AU500014234的工作编号。我想脚本删除AU5000,留下剩下的5个数字,即14234

function fandr() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var s=ss.getActiveSheet();
var r=s.getDataRange();
var vlst=r.getValues();
var i,j,a,find,repl;
find="AU5000";
repl="";
for (i in vlst) {
for (j in vlst[i]) {
a=vlst[i][j];
if (a==find) vlst[i][j]=repl;
}
}
r.setValues(vlst);
}
提前感谢

这可以在应用程序脚本中完成,使用 样本:

function replaceAllSubstrings(){
  var find="AU5000";
  var repl="";
  SpreadsheetApp.getActive().getActiveSheet().getDataRange().createTextFinder(find).replaceAllWith(repl);  
}