Clear Data (Except Formulas) in Google Sheets with Custom Sheet and Range
This Google Apps Script clears all data in a user-specified range of a user-specified sheet in your Google Sheet while preserving formulas. Follow these steps to use it:
- Open your Google Sheet.
- Click on Extensions > Apps Script in the top menu.
- In the Apps Script editor, paste the code below.
- Save the script with a name (e.g., "ClearData").
- Run the script by clicking the play button in the Apps Script editor. You may need to grant permissions the first time.
- When prompted, enter the name of the sheet (e.g.,
MySheet
) in the first dialog box. - If the sheet name is valid, a second dialog box will prompt you to enter the range (e.g.,
A1:Z50
). - Click OK to proceed or Cancel to abort at either prompt.
- Check your sheet—data will be cleared, but formulas will remain!
- If an invalid sheet name or range is entered, an error message will appear.
No comments:
Post a Comment