I am trying to use Office Script to i) delete a column with a header named "Object Type" and
ii) sum up the cells (all the visible filtered cells) in the column named "Hits".
I'm new to Office Script and am stuck. I get the following error for getColumnByName: Cannot read properties of undefined (reading 'getColumnByName')
Any help will be super appreciated!
ii) sum up the cells (all the visible filtered cells) in the column named "Hits".
I'm new to Office Script and am stuck. I get the following error for getColumnByName: Cannot read properties of undefined (reading 'getColumnByName')
Any help will be super appreciated!
VBA Code:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
let table = workbook.getTables()[0];
//delete a column with a header named "Object Type"
let rangeObj = table.getColumnByName("Object_Type").getRange();
selectedSheet.getRange(rangeObj).delete(ExcelScript.DeleteShiftDirection.left);
//Sum up the cells (all the visible filtered cells) in the column named "Hits"
let rangeHits = table.getColumnByName("Hits").getRange();
selectedSheet.getRange(rangeHits).???
}
Sample | Object Type | Hits | |
1 | A | 24 | |
2 | B | 3444 | |
3 | C | 334 |