Introduction

Introducing Small Toggle Buttons

Small Toggle Buttons - compact animated buttons to use as a switch to toggle an option or setting for Excel

These small Toggle Buttons can be used as a switch to toggle a setting On/Off in Excel. Designed from scratch, I use 2 Shapes and 1 Graphics object (an Icon) grouped together to create each Button. I suffix each group with 1, 2, 3 etc. to allow the code to distinguish which Button is being activated on a Sheet. Then I link up a Subroutine to animate the Button and the Icon - in some examples, the code also changes the colour of the cylinder from grey to orange when the Button is switched on. The code uses my IEasing Class to demonstrate 4 different types of easing or movements for the Buttons, easeInExpo, easeOutBack, easeOutElasticSmall and easeOutQuintic

If you like this Project you may also enjoy


Flat UI ·  Awesome Buttons ·  Slider Toggle Buttons ·  Sliders ·  Menubar ·  Toggle Buttons ·  xlui ·  RadiObutton ·  CheckboX ·  Burger Buttons ·  Popup Burger Buttons

Prerequisites

  • Excel 2013 (Version 5) & Excel 2016 (32bit or 64bit, Version 8)
  • Basic to moderate Excel Skills and some VBA skills to copy a Grouped Shape and then link a Subroutine to a Shape and a Graphic object
  • Windows PC · NOT a Mac!
  • No support is provided for customization of this Software

Features

  • Copy the Grouped Shapes/Icon to make more small Toggle Buttons
  • Store the Toggled values in the Sheet or as Defined Names/other Ranges
  • Easing animations include easeInExpo, easeOutBack, easeOutElasticSmall and easeOutQuintic
  • Use SVG Icons and change their Colour
  • Style the Cylinder to create an On/Off look and feel
  • Silky-smooth easing animations (approx. 25 different easing motions are available for you to try, some may/may not be useful in the Slider Button context ie. easeInBounce)
  • Use my nifty Options Group to layout a series of Small Toggle Buttons in a Frame
  • Protect the Shape and Graphic Drawing Objects via VBA Code to prevent Selection








Installation

Small Toggle Buttons.xlsm is ready to use (version specific naming of the file may differ with each new release). Open the Small Toggle Buttons.xlsm File and test out the Buttons on the various Worksheets to see how they animate and toggle their respective setting values On/Off. In order to select any of the Shapes or Graphic Objects you must first Unprotect the Sheet

Usage

Small Toggle Buttons.xlsm


Using the Small Toggle Buttons in your own Project
To use the Small Toggle Buttons in your own Project, first Unprotect the Interface by doing Unprotect Sheet on the Protect Group of the Review Tab on the Ribbon. Right-click a Shape and use the Selection Pane on the Editing Group of the Home Tab of the Ribbon to make Selections easier. Now, Copy the Shape (it's Grouped, so select the overall Group Shape object) and Paste onto any Worksheet. If you need more than one set of Toggle Buttons then repeatedly Paste more until you have the amount that you need. Now rename the Toggle Button Shapes and individual Shapes using the suffix 1, 2, 3, 4 etc. The Code uses the Application.Caller() method to retrieve the Grouped Toggle Name and with this, it can then find the Cylinder and the collection of Shapes/Icons Group Name - it is still wise to make all of the Shapes have unique Names as this is good practice, ie. Icon, Button and Cylinder - the way that I have written the Code means that no Names need to be hard-coded. Remember to use the Selection Pane to do this as it's easier and you can see what you are changing. Now Copy the Code in one of the Code Modules into your own Project Worksheet Code Module. Link the Code by selecting both the Icon and SliderButton in turn and then right-click assign macro - pick the Subroutine that you just copied. That's it, click one of the Toggle Buttons to protect the Interface and trigger the animation. The Code below details how the grouped Shape is known via Application.Caller(). Oh, remember to add the IEasing Class to your Project/Workbook - you can open the VBE Editor and simply drag this from one Project into another Project using the Project Pane (top LHS):
    
   ' assign all of the Shapes/Graphics used by the slider toggle buttons
   Set Toggle = ActiveSheet.Shapes(CStr(Application.Caller)).ParentGroup
   Set Icon = ActiveSheet.Shapes(Toggle.Name).GroupItems(3)
   Set Button = ActiveSheet.Shapes(Toggle.Name).GroupItems(2)
   Set Cylinder = ActiveSheet.Shapes(Toggle.Name).GroupItems(1)



Adding the Macro
You need to add any of the Code Module Macros/Subroutines to both the Icon and the SliderButton Shape only, not the Cylinder (unless in the case of my favourite, Toggle2 Demo) or the Group, Toggle Shape. You should use the Find & Select, Selection Pane to highlight the Icon and the SliderButton and then right-click on it and assign the Macro. Always use the same Macro for the Icon and the Slider Button within each grouped set of Shapes. Please Note: when starting a new Project and Copying over the Buttons, Save the Project when you have finished and added the Macros to the Toggle Buttons and then Close the File! Reopen it and test the Slider Toggle Buttons

Changing the Colours of the Cylinder Shape
Changing the Colour of the Cylinder Shape is easy. Go into the Code and in the Subroutine, scroll down to the bottom of the Code. To change the Colour of the Cylinder for either On or Off, change the RGB values of the Cylinder:
    
   If Direction Then
      ' right, On
      Cylinder.Fill.ForeColor.RGB = RGB(168, 194, 83)
   Else
      ' left, Off
      Cylinder.Fill.ForeColor.RGB = RGB(158, 158, 158)
   End If



Storing the On/Off value of the Slider Toggle Buttons
You can store or capture the On/Off status of any of the Slider Toggle Buttons via code either in a Defined Name or Named Range or in a Cell/Range ie. [Slider1].value2 = "On" or ActiveSheet.Range("A100").value2 = "On". Below I simply output the result to the offset of the Cylinder object a couple of Columns next to the object itself:
    
   If Direction Then
      ' right, On
      Cylinder.Fill.ForeColor.RGB = RGB(168, 194, 83)
      Cylinder.BottomRightCell.Offset(-1, 2).Value2 = "On"
   Else
      ' left, Off
      Cylinder.Fill.ForeColor.RGB = RGB(158, 158, 158)
      Cylinder.BottomRightCell.Offset(-1, 2).Value2 = "Off"
   End If



Changing the Alt. Text of the Small Toggle Buttons
I have done the hard work for you already, however if you have an error when creating a new Toggle Button if you use your own Shapes then remember to edit the Alt. Text as per the image below (set to True or False for the Code to work correctly when using my Subroutines and easing functions). This setting determines whether the Code will make the Icons and Buttons move right or left. Once the code has ran once, the setting will be automatically updated:





SVG Icons
The Slider Toggle Button uses an SVG Icon. To change the Icon, you first need to Unprotect the Worksheet. Then right-click the Graphic Object or any Shape and use the Selection Pane on the Editing Group of the Home Tab of the Ribbon to select the Icon in a Toggle Group. Now choose, change Graphic, from Icons on the Change Group of the Graphics Format Tab on the Ribbon and pick another Icon. Here I am changing the Icon to a Plus Icon





Tips
Speeding up the animations:
To speed up the animations, go into the code and in any of the Code Modules, change the 24 in 'TweenTime = TweenTime + 1 / 24' to a lower number ie. 12. If this does not work for some animations, increase the timer refresh rate ie. From 40 per second to 60 per second

Resizing the Small Toggle Buttons to create larger or smaller ones:
Unprotect the Worksheet and select the Toggle Grouped Shape. Hold down Shift and then drag the object to resize it. Now adjust the MoveAmount variable in the Code to a larger or smaller value (please note: you may have to tweak the positioning of the Icon and the Slider Button to get the Button sliding to each end equally depending on the type of easing function used). The MoveAmount variable determines how far right and left that the Icon and Button will move for each Mouse Button press

Slider Toggle Buttons

The Small Toggle Buttons in all of their splendour!

The Small Toggle Button displayed on a white background at 100% Zoom

An Options Group featuring the Small Toggle Buttons

FAQ

Q. How do I speed up the Slider Button animations?
A. To speed up the animations, go into the code and in any of the Code Modules, change the 24 in 'TweenTime = TweenTime + 1 / 24' to a lower number ie. 12. If this does not work for some animations, increase the timer refresh rate ie. From 40 per second to 60 per second


Small Toggle Buttons

This is a video of the Small Toggle Buttons

Support

Please remember you have purchased very affordable Software and you have not paid for a full-time Software design agency - I am but one man. Occasionally I may help with small tweaks, but these requests will be put on a much lower priority due to their nature. You have not PAID for Support, Support is 100% optional and I provide it for your convenience, so please be patient, polite and respectful

Support (limited) for my Software includes

  • Responding to questions or problems regarding the Software and its features
  • Fixing valid (replicated) bugs and reported issues for the VERSION I HAVE WRITTEN

Software support does not include

  • Customization and installation services
  • Support for third party software or ANY kind of development whatsoever

Before seeking support

  • Make sure your question is a valid Software Issue and not a customization request
  • Make sure you have read through the FAQ's, online documentation and any related video guides before asking support on how to accomplish a task
  • Ensure that you access to the VBOM is allowed and that Macros can run in Excel
  • Make sure to provide 'proof of purchase' and state the name / version of the Software that you are having issues with when requesting support by Email or via Facebook

How to get Support

Contact Mark Kubiszyn on the Email address provided when you purchased the Software, including the Order Number
...or Contact Mark Kubiszyn via our Facebook Page - remember to be patient, if there has been an issue with your download, Mark will always respond within 48 hours and will Email you the File directly if neccessary or via Messenger. For other issues the response time may be considerably longer and I may choose to respond to specific questions only (as is my right), depending on what has been asked

Future Builds

* No ideas as yet!

Bug Fixes

* There are currently no bugs identified

Changelog

You can find the version history in the Code Module for any Macro-enabled Software or read more information on the status of each release
- the latest Version including a description of any changes made is always shown first

22.06.2021 - (Version 1) general release