Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 12th, 2018, 08:50 PM
Authorized User
Points: 378, Level: 6
Points: 378, Level: 6 Points: 378, Level: 6 Points: 378, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2009
Posts: 67
Thanks: 6
Thanked 0 Times in 0 Posts
Default Toggle Buttons

Hi,

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
Khalil
Reply With Quote
  #2 (permalink)  
Old April 30th, 2018, 03:56 PM
Wrox Author
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2011
Location: San Francisco / Silicon Valley
Posts: 16
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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
Reply With Quote
The Following User Says Thank You to tomurtis For This Useful Post:
Khalil (May 1st, 2018)
  #3 (permalink)  
Old May 1st, 2018, 03:14 PM
Authorized User
Points: 192, Level: 3
Points: 192, Level: 3 Points: 192, Level: 3 Points: 192, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2015
Location: South Africa
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
Reply With Quote
The Following User Says Thank You to Zakalwe For This Useful Post:
Khalil (May 1st, 2018)
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle a button pottsmgg Visual C++ 0 July 31st, 2010 10: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 04:36 AM
Language toggle dsunmedia PHP How-To 2 August 2nd, 2004 12:00 PM



All times are GMT -4. The time now is 03:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.