我希望使用鏈接到按鈕的腳本來自動化 (Ctrl H) 的查找和替換功能,原因是在作業表上我們使用的替換文本始終是“zold” “原始文本”,作業表是一個多頁日志,需要在與確切文本匹配的多張紙上查找和替換。我可以設定一個簡單的查找和替換,但在參考活動單元格時似乎無法讓它作業。任何指標將不勝感激。
這是我嘗試過的,查看檔案我不確定如何將當前單元格從“getActiveRange”組合到文本中,然后替換搜索條件。
function markOld() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var textFinder = sheet.createTextFinder();
.matchEntireCell(true)
.matchCase(true)
.matchFormulaText(false)
.ignoreDiacritics(false)
.replaceAllWith('zold' .getActiveRange());
}
uj5u.com熱心網友回復:
假設你的大部分代碼是正確的......
function markOld() {
let sheet = SpreadsheetApp.getActiveSpreadsheet();
let cell_value = sheet.getCurrentCell().getValue(); // Find value of current cell https://developers.google.com/apps-script/reference/spreadsheet/sheet#getcurrentcell
sheet.createTextFinder(cell_value) // <-- Removed the ';' and added cell_value
.matchEntireCell(true)
.matchCase(true)
.matchFormulaText(false)
.ignoreDiacritics(false)
.replaceAllWith('zold' cell_value);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/460001.html
上一篇:僅對給定字串的數字求和
