One of the interactive features that I wanted to create was a spin button (or scroll bar) functionality, where the user can simply click on it and the value of a cell change. Show
While it’s easy to insert and use spin buttons or a scroll bar in Excel, unfortunately, the same is not available in Google Sheets. So I had to take the longer route of using two shapes and adding some Google Script at the back end. This is what I created using it: Click here to access this Google Sheets document! In this tutorial, I will show you the exact steps that I followed to create this kind of spin button functionality in Google Sheets. This Article Covers: Spin Button in Google SheetsThere are three parts to creating a spin button in Google Sheets:
Inserting triangles that look like Spin ButtonHere are the steps to insert shapes (triangles) in Google Sheets:
This will insert the shape in the Google Sheets. You can resize it and place it where ever you want on the sheet. The result of this section would be something as shown below. Here I have the two triangles (the yellow cell is the one I will link to these triangles in the next two sections). Writing the Google ScriptNow we need to add a Google Script code for each button. To do this, we will create two functions – ‘Increment’ and ‘Decrement’. Here are the codes for each function: Increment Number by 1:function increment() { SpreadsheetApp.getActiveSheet().getRange('C5').setValue(SpreadsheetApp.getActiveSheet().getRange('C5').getValue() + 1); } Decrement Number by 1:function decrement() { SpreadsheetApp.getActiveSheet().getRange('C5').setValue(SpreadsheetApp.getActiveSheet().getRange('C5').getValue() - 1); } Here are the steps to add these scripts to the backend of Google Sheets:
The above steps create two new functions in the Google Sheets. Now we need to assign these functions to the shapes (triangles) that we inserted. Assign the Google Script to the shapeHere are the steps to assign a script to an object:
Repeat the same process for the other triangle, and assign ‘decrement’ script to it. That’s it! Now when you click on the triangle with ‘Increment’ function assigned to it, it will increment the number value in cell C5 by 1. Similarly, clicking on the other triangle will decrement in the value in cell C5 by 1. Additional Notes:
So this is how you can create a spin button in Google Sheets (some people also call it a spinner) and use it to increment/decrement the value by a specific margin. Want to become a Google Sheets expert? We highly recommend checking out Udemy’s Google Sheets Comprehensive Masterclass and the Complete Google Sheets Course.
SumitSpreadsheet Expert at Productivity Spot |+ posts Sumit is a Google Sheets and Microsoft Excel Expert. He provides spreadsheet training to corporates and has been awarded the prestigious Excel MVP award by Microsoft for his contributions in sharing his Excel knowledge and helping people.
Popular PostsHow to Duplicate a Google Sheet: Quick & Easy GuideSix Sigma Certification: The Ultimate GuideHow to Use the DATE Google Sheets Function [Easy Examples]How to Find a WiFi Password on an iPhone [5 Easy Ways]8 thoughts on “How to Insert Spin Button in Google Sheets (+1 Increment Buttons)”
|