Introduction

Introducing Toggle Buttons

Toggle Buttons - use as a switch to toggle an option or setting for Excel

I have been meaning to create some of these little beauties for a while now. I have grouped 2 Shapes, a Toggle Button and a Cylinder to make a nifty Toggle Button that can be copied into a Worksheet. After that, you can then add/link the small VBA Code Subroutine to do the toggling work and to store or update the On/Off values. These Buttons are my own design and Code. I took the Colours for the Demo from an image I found by searching on Google. Then I added a nice little easing function for the smooth animation. The easing function is a Robert Penner easing function called 'easeInQuad'

I have now added in an extra Sheet to demonstrate using SVG Icons with the ToggleButtons. You need to use a Graphic Object alongside the Toggle Buttons and Cylinders for the Icon. This allows you to change the colour of the Icon and to resize it within the Toggle Button nicely

I have included a design based around a concept image sent to me from Andrew Landsman, who also helped in idenfication of the Zoom issue - view the images here (scroll to the bottom)

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
  • Windows PC · NOT a Mac!
  • No support is provided for customization of this Software

Features

  • Copy the Grouped Shape to make more Toggle Buttons
  • Store the Toggled values
  • Use SVG Icons and change the Fill and Line Colour
  • Style specific ToggleButton Groups using a Case Select Code statement
  • Add Drop-shadow effects to your ToggleButtons
  • Protect the Shape and Graphic Drawing Objects via VBA Code to prevent Selection
















Installation

ToggleButtons.xlsm is ready to use (version specific naming of the file will differ with each new release). Open the ToggleButtons.xlsm File and test out the Demo Toggle Buttons. There are 3 Sheets, Togglebuttons, Dark Togglebuttons and Togglebuttons with Icons. In order to select any of the Shapes or Graphic Objects you must first Unprotect the Sheet

Usage

ToggleButtons.xlsm


Using the Toggle Buttons in your own Project
To use the Toggle Buttons in your own Project, first Unprotect the Interface by just 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) 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 2, 3, 4 etc. The Code uses the Application.Caller() method to retrive the Toggle Button Name and with this, it can then find the Cylinder and the Group Name - it is still wise to make all of the Shapes have unique Names as this is good practice, but 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 the Sheet1 Code Module into your own Project Worksheet Code Module. That's it, click one of the Toggle Buttons to protect the Interface. The Code below details haow the Toggle Button and Cylinder are known via Application.Caller():
    
   ' assign Shapes, we use 1 x Cylinder and 1 x ToggleButton and Group them together as Toggle so the we do not have to hard-code any Names
   Set Toggle = Me.Shapes(CStr(Application.Caller)).ParentGroup
   Set ToggleButton = Me.Shapes(CStr(Application.Caller))
   Set Cylinder = Me.Shapes(Toggle.Name).GroupItems(1)



The Toggle or Click Macro
You need to add the Sheet1.Toggle Macro to the ToggleButton Shape only, not the Cylinder or the Group, Toggle Shape if you only want the Toggle Button to be clicked. If you want to allow the user to click anywhere on the Toggle Button to fire the animation, then add the Macro to the Cylinder Shape as well. You should use the Find & Select, Selection Pane to highlight the ToggleButton and then right-click on it and assign the Macro. Always use the same Macro for different Toggle Buttons and/or Cylinder 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 Toggle Buttons

Changing the Colours of the Toggle Button and the Cylinder Shapes
Changing the Colour of the Shapes is easy. Go into the Code and in the Toggle Subroutine, scroll down to the bottom of the Code. To change the Colour of the Cylinder, change the RGB values of the Cylinder and to change the Colours of the Toggle Button, change the Fill and Line (Border) RGB values of the Toggle Button. Do this for both RGB values for each Shape Object as per below (you can also use long Colours):
    
   ' style according to the current direction applied to the Toggle (this is the switched On direction)
   If Direction Then
      Cylinder.Fill.ForeColor.RGB = RGB(77, 182, 172)      ' the Cylinder

      ToggleButton.Fill.ForeColor.RGB = RGB(128, 203, 196) ' the circle of the Toggle Button
      ToggleButton.Line.ForeColor.RGB = RGB(224, 242, 241) ' the outer circle or border of the Toggle Button 



Changing the Alt. Text of the ToggleButton
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 Subroutine and easing function):





SVG Icons
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 ToggleButton Group. Now choose, change Graphic, from Icons on the Change Group of the Graphics Format Tab on the Ribbon and pick another Icon





Alien Concept Icons
One of the users of this Software came up with a couple of nice Alien designs to use for Toggle Buttons. You can check these out below - love the grey Alien! Contact Andrew on Andrew Landsman if you would like to use his images







Tips
To make smaller/large Toggle Buttons, Copy a Group Toggle and then hold down Shift and using the Mouse, drag one of the corners to resize the Shapes. Now rename the Grouped Toggle and all of its Shapes using a new suffix and then link up the required Macro for the animations. Making smaller Toggle Buttons allows you to maintain smaller Toggle Buttons in lines within a Worksheet for a more compact visual UI/UX

Toggle Buttons

The Demo Toggle Buttons, one is switched On and the other is switched Off

Dark Mode Toggle Buttons are more compact

Toggle Buttons using SVG Icons

More Toggle Button Examples

The Toggle Button background Colours are easy to Change - here is a Screen Shot I did by changing the Toggle Button Fill and Line (or Border) Colour and the Cylinder Fill Colour

FAQ

There are no Q & A for the Toggle Buttons


Toggle Buttons

This is a video of the Toggle Buttons Demo

This is a video of the Toggle Buttons Dark Mode Demo which uses compact, purple 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

24.06.2021 - (Version 1.3)

Bug fix: the Button to respond to the Toggle Button status on the More Examples Sheet did not give the correct result as the Defined Name was referring an incorrect Cell
Added a Boolean variable to ensure that a user cannot double-click a Toggle Button and fire the Code multiple times. This now allows you to click the Toggle Buttons really fast to swap them back and forth
Made some tiny Toggle Buttons by resizing the Grouped Toggle and holding down Shift
Added another Toggle Button on the front Sheet to demonstrate allowing the user to click anywhere on the Toggle Button to fire the animation
Renamed the file ToggleButtons (specific version information will be added on the front Sheet)

18.06.2021 - (Version 1.2)

Tidied up the Code. Added a fix for when Excel is Zoomed and the Togglebutton Shape moved. Added a new Sheet that demonstrates using SVG Icons with the ToggleButtons. You can now Style the colour of the Icons and also style specific ToggleButton Groups using a Case Select statement in the code

06.12.2020 - (Version 1.1)

Added a Dark Mode with some compact Toggle Buttons

04.12.2020 - (Version 1) Released

General release of the first version of Toggle Buttons