Forum Discussion

Jim_Currier__NPL's avatar
Jim_Currier__NPL
Copper Contributor
Feb 08, 2023

Office Scripts - Clear Cell Button

Hi Guys, Anyone any good with Office Scripts? I want to add a 'Clear' button to the Excel web version. Tried using similar script to the normal VBA but doesn't work. If anyone knows what the Offi...
  • rzaneti's avatar
    rzaneti
    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.

Resources