以前質問をさせていただいた者です。
スプレッドシートのマクロ機能を使って一括置換をしたいのですがうまくいきません。。
したいこと↓↓
あああ(reg)タブのG列を、「種別置換タブの置換前のデータに該当する文字列を置換後データの文字列に一括で置換したい」です。
(例)
置換前データ
種別置換タブのB2-B10
置換後データ
種別置換タブのC2-C10
置換対象
あああ(reg)タブのG列(G1はヘッダーなので覗く)
変更する、あああ(reg)のタブ名は仮です。
種別置換とあああ(reg)は同じスプレッドシート内の別タブになります。
以下が実行したスプリクトです。
function あああreg() {
const targetSheetName = "あああ(reg)";
const targetA1notation = "G:G";
const dictionarySheetName = "種別置換";
const dictionaryA1Notation = "B2:C10";
const spreadsheet = SpreadsheetApp.getActive();
const targetRange = spreadsheet
.getSheetByName(targetSheetName)
.getRange(targetA1notation);
const dictionary = spreadsheet
.getSheetByName(dictionarySheetName)
.getRange(dictionaryA1Notation)
.getValues();
dictionary.forEach(function(e) {
targetRange.createTextFinder(e[0]).replaceAllWith(e[1]);
});
}
ご指導をお願いいたします。
回答1件
あなたの回答
tips
プレビュー