0

I have an Excel sheet, which is filtered with slicers and contains a column with checkboxes. I would like to create a script which reverses the values of the visible checkboxes.

I'm new to TypeScript, but I've constructed the basic structure. Problem is; because the column contains a header, I need to check the cellValue for a checkbox, before I flip the value. Unfortunately, typeOf only returns "object" and checking with instanceOf didn't work either. What would be the best approach to identify cells only with checkboxes?

Thanks in advance

function main(workbook: ExcelScript.Workbook) { let selectedSheet = workbook.getActiveWorksheet(); // get all the visible cells in the 'complete' column let visibleCheckboxes = selectedSheet.getRange("F:F") .getUsedRange() .getSpecialCells(ExcelScript.SpecialCellType.visible) // iterate over the all the checkboxes and flip their value visibleCheckboxes.getAreas().forEach((range) => { // mulitple ranges as we're filtering range.getValues().forEach(cellValue => { console.log(typeof cellValue) // if cellValue is a checkbox // flip value }); }); } 
1
  • cellValue is an array, you need to use typeof cellValue[0] to get the type from the actual value. Commented Jun 12 at 14:58

1 Answer 1

0

I've resolved this, by exlcuding the header in the first place, leaving me with only checkboxes in the range, which I can then set their value

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.