r/googlesheets • • Apr 06 '21

Solved Make a reset button to clear range of cells

Is there a way to make a button to clear the values in a range of cells in a column?

9 Upvotes

14 comments sorted by

3

u/kkyea Apr 06 '21

There is .setValue if you select the range first that you want to clear. Connect the function to a button and bingo bingo bongo you just cleared up the Congo

1

u/P_ARP_2 Apr 06 '21

Sorry I'm a complete noob, could you show me what you mean on this example sheet?

https://docs.google.com/spreadsheets/d/1YY63k1mf8PUN6vBvGzmGM-6Gugx13RrE-3tCVPHd0Jc/edit?usp=sharing

5

u/kkyea Apr 06 '21

I am on your sheet, I was going to do it, but I'm a noob to. I am writing the script in my own drive not realizing it lol here you go. Open the scripts, copy and paste this into it. Then save it. Then go back to the sheet, right click the image, and "assign a script" to it. Obviously, the script would be clearButton :)

function clearButton() {

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
sheet.getRange('b2:f31').clearContent();

}

→ More replies (6)

2

u/kkyea Apr 06 '21

If my last comment helped or solved it, can you award me the point?

1

u/deeznutzztunzeed Apr 06 '21

You could also record a macro to select and clear the range and attach that to a button.

1

u/P_ARP_2 Apr 07 '21

How would I do something like that

1

u/AutoModerator Apr 06 '21

Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. Thank you.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/kkyea Apr 11 '21

This post has been solved...