Wrox Programmer Forums
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 12th, 2018, 07:50 PM
Authorized User
Join Date: Dec 2009
Posts: 69
Thanks: 6
Thanked 0 Times in 0 Posts
Default Toggle Buttons


I have four worksheets and each one of them has a toggle button. All those buttons do the same thing. So if the user is working on Sheet2 and decided to click the toggle button, I would like to make the other three buttons in the other sheets to be clicked or depressed automatically. Is this can be done? if yes, how?

Thank you
Old April 30th, 2018, 02:56 PM
Wrox Author
Join Date: Apr 2011
Posts: 16
Thanks: 0
Thanked 2 Times in 2 Posts

Well, let's see.
If it were me, and there were a dozen or more controls to behave the same way, I'd use a class module. Seeing as there are only 4, one on each sheet, I'd write a macro to do what you want by looping through each sheet's respective toggle control and do what you want. Let's say you name that macro myToggleTask. Then it's a simple matter of going one by one to each toggle control and for its respective Click event, run the myToggleTask macro by putting this one-liner in the code:

Private Sub ToggleButton1_Click()
Run "myToggleTask"
End Sub
The Following User Says Thank You to tomurtis For This Useful Post:
Khalil (May 1st, 2018)
Old May 1st, 2018, 02:14 PM
Authorized User
Join Date: Oct 2015
Posts: 48
Thanks: 0
Thanked 5 Times in 5 Posts
Default It can be done without writing code.

Open VBA Editor, put it in design mode.
Choose to view properties of each toggle.
Point the LinkedCell of the toggle to the cell you want the toggle to update to.
For cells on different sheets you'll write the full cell reference: SheetName!CellAddress.
If you have a Worksheet named Data with a cell A2 you want the toggle to update: Data!C2.
Remove VBA from design mode and Bob's your uncle.
Nostalgia 4 Infinity
The Following User Says Thank You to Zakalwe For This Useful Post:
Khalil (May 1st, 2018)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle a button pottsmgg Visual C++ 0 July 31st, 2010 09:49 PM
Toolbar toggle buttons in C# 2005 chroniclemaster1 C# 2005 0 December 18th, 2007 11:38 PM
Toggle/Drilldown help...please!!! s15199d Reporting Services 4 March 24th, 2006 04:11 PM
Toggle Buttons ctekk2005 Access 3 June 15th, 2005 03:36 AM
Language toggle dsunmedia PHP How-To 2 August 2nd, 2004 11:00 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.