Forum Discussion
Office Scripts - Clear Cell Button
- Feb 09, 2023
Hi Jim_Currier__NPL ,
If you want to keep the formats and just clear the values inside the cells, this is an alternative code:
workbook.getActiveWorksheet().getRange('C2:C8').setValues([[""], [""],[""],[""],[""],[""],[""]])
Here we are just assigning "" to all cells in the range C2:C8. There are more effective ways to write this code if you need it for more than 7 cells.
Please, test it and let me know if it works for you.
Hi rzaneti,
That worked, however.................
I need the formulas to stay in place and just clear data entered in the cells.
That just cleared everything.
Sorry should have said at the start.
Kind Regards,
Hi Jim_Currier__NPL ,
If you want to keep the formats and just clear the values inside the cells, this is an alternative code:
workbook.getActiveWorksheet().getRange('C2:C8').setValues([[""], [""],[""],[""],[""],[""],[""]])
Here we are just assigning "" to all cells in the range C2:C8. There are more effective ways to write this code if you need it for more than 7 cells.
Please, test it and let me know if it works for you.
- Jim_Currier__NPLFeb 10, 2023Copper Contributor