我有两篇文字,从谷歌表中删除案文。 这两本书在更新时都自动启动,但两本书都试图将同一个牢房隔开,而只是应用其中一项功能。
Oringinal cell text example: From: Leigh-on-sea, ss9, UK Building No. Street & Postcode: 123 street address UK Distance: 0.7m Duration: 4 min
删除案文的职能:“标题:
function removeTags() {
var column = 11
var sh = SpreadsheetApp.getActive().getActiveSheet();
var data = sh.getRange(1, column, sh.getLastRow(), 1).getValues();
for (var n in data) {
if (data[n][0] == ) { continue };// if cell empty then continue
var str = data[n][0].toString();
var location = str.indexOf("Postcode: ");
if (location != -1) {
data[n][0] = str.substring(location + 10, str.length - 1);//remove everything BEFORE Postcode:
}
}
sh.getRange(1, column, sh.getLastRow(), 1).setValues(data);// update sheet with new data
}
Function to remove text AFTER "Distance: "
function removeTags(){
var column = 11
var sh = SpreadsheetApp.getActive().getActiveSheet();
var data = sh.getRange(1,column,sh.getLastRow(),1).getValues();
for(var n in data){
if(data[n][0]== ){continue};// if cell empty then continue
var str = data[n][0].toString();
data[n][0]= str.substring(0,str.indexOf("Distance: "));//remove everything after Distance:
}
sh.getRange(1,column,sh.getLastRow(),1).setValues(data);// update sheet with new data
}
这两项职能在单独运作时都是预期的,但当新财产被送至表格时,则只适用第一份触发/说明。 我需要把文字合在一起,以便有一个单一的触发点。
I tried editing a bit of the script a few way to figure it out myself, but failed.