我是Google脚本的新手,我无法更新一行然后移至google表格中该列的下一行...下面的代码更新了单元格(A3),但是当您运行时该代码再次更新同一行。我的直觉是If LCase(ws.Name) Like "*ba*" Then
ws.Visible = xlSheetVisible
ws.Select Not flg
flg = True
End If
部分...虽然对Google表格语法不太熟悉...任何帮助将不胜感激!
A3
答案 0 :(得分:3)
您可以使用here中记录的脚本属性。可以在File > Project properties > Script properties
中手动配置脚本属性。您可以使用它来跟踪要更新的下一行,例如
function getProfolioPrices() {
var activeSheet = SpreadsheetApp.getActiveSheet();
var nextRowNumber = getNextRowNumber();
activeSheet.getRange('A' + nextRowNumber).setValue('=GOOGLEFINANCE("TTWO", "price")');
activeSheet.getRange('C' + nextRowNumber).setValue('=GOOGLEFINANCE("TSLA", "price")');
activeSheet.getRange('E' + nextRowNumber).setValue('=GOOGLEFINANCE("AMZN", "price")');
activeSheet.getRange('G' + nextRowNumber).setValue('=GOOGLEFINANCE("NEP", "price")');
}
function getNextRowNumber(){
var scriptProperties = PropertiesService.getScriptProperties();
var nextRowCounter = scriptProperties.getProperty( 'nextRowCounter' );
if ( isNaN( parseInt( nextRowCounter ) ) ) {
nextRowCounter = 1; //Default to 1
} else {
nextRowCounter++;
}
scriptProperties.setProperty( 'nextRowCounter', nextRowCounter );
return nextRowCounter;
}