I Know this is pretty simple for experienced developer of Google App Script. I am new to Google App Script and trying on this since 2 days so I came here.
Let me explain the scenario, we have an Google Sheet add-on. When user do some query using our add on, we keep query id[A column], Sheet name[B column] and updated cell range[C column] in a hidden sheet as shown in image.
Now We want to update these ranges if user add/remove column/row from the sheet.
e.g we have range J4:k14 in the sheet. e.g User add column left of C, then the J4:K14 range shift to K4:L14.
function onChange(e) {
if (['EDIT', 'INSERT_ROW', 'INSERT_COLUMN', 'REMOVE_ROW', 'REMOVE_COLUMN'].includes(e.changeType)) {
var range = SpreadsheetApp.getActiveRange();
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var querySheet = activeSpreadsheet.getSheetByName("OurHiddenSheet");
// First I want to read C column to get values. that will be assigned in **range**.
var addresses = Sheets.Spreadsheets.Values.get(querySheet.getSheetId(), range);
// Since addresses contain all ranges, I can create RangeList from this.
var rangeList = activeSpreadsheet.getRangeList(addresses);
// Is there any function available in Google App Script, if the Range was impacted by the operation or not?
}
}
How to read the entire B and C column and filter based on current sheet name and range?
I want to know, Is there any functions available to know if the range was impacted by the operation?
Now We want to update these ranges if user add/remove column/row from the sheet. e.g we have range J4:k14 in the sheet. e.g User add column left of C, then the J4:K14 range shift to K14:L14. How to read the entire B and C column and filter based on current sheet name and range?
. Can I ask you about the detail of it? – Tanaikee.g we have range J4:k14 in the sheet. e.g User add column left of C, then the J4:K14 range shift to K4:L14. How to read the entire B and C column and filter based on current sheet name and range?
. – TanaikeOpen a sheet Put some data in D2:E2 range. Add a column left to C column. The data which we added D2:E2 range, it's new position is E2:F2 .
and your image and script. – Tanaike