GAS初心者です。GASにおいて同列内の複数セルの中から特定の文字列より前を削除したいのですがどうすればいいでしょうか?
列1 | 列2 |
---|---|
abcde=fg | fg |
asfgde=orange | orange |
jhddthyjde=apple | apple |
このような感じで、de=
より前の文字を削除してそれより後の文字列だけを表示したいです。
実際に書いたコードは、
JavaScript
function myFunction() { const ss = SpreadsheetApp.getActiveSpreadsheet(); let sheetName = '抽出' const sheet = ss.getSheetByName(sheetName); const lastRow = sheet.getLastRow(); let status_list=sheet.getRange(1,1,lastRow,1).getValues(); const a = "de="; const b = status_list.slice(status_list.indexOf(a)) sheet.getRange(1,2,lastRow,1).setValues(b); console.log(b); }
で、次のようなエラーが出ました。
Exception: The number of rows in the data does not match the number of rows in the range.
二次元配列に対して、出力しているb
の値が1個だからだと思うのですがそれをどううまく表示させればいいかわかりません。
ご教授いただけますと幸いです。
まだ回答がついていません
会員登録して回答してみよう