Solved

Toggle button

Posted on 2014-10-28
7
151 Views
Last Modified: 2014-10-28
Hi,

I have two subs "Full" and "Small"

I have two buttons for these subs (they determine whether excel is in full screen mode or not)

I would like one button that defaulys on entry to the spreadsheet to "Small" then if that is clicked, changes to "Full"

This is to make the spreadsheet cleaner

Many thanks
Seamus
0
Comment
Question by:Seamus2626
  • 3
  • 2
  • 2
7 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
Comment Utility
You have entered this under "Visual Basic Classic", yet you refer to a spreadsheet, which makes me believe you are talking about VBA.

Please clarify.
0
 

Author Comment

by:Seamus2626
Comment Utility
Well, the buttons are from the developer tab and activating VB code on pressing them, so its both excel and VB

Thanks
0
 
LVL 24

Expert Comment

by:Phillip Burton
Comment Utility
No, it's Excel and VBA. VB is a separate application - it's part of Visual Studio, or a 12 year old application,  It's very important to get that terminology right, otherwise people might think that you are trying to interact Visual Studio with Excel.

So, now I know what you are talking about, please find attacehd a sample workbook with that button.

The VBA is as follows:

Sub Button1_Click()
With ActiveSheet.Shapes("Button 1").TextFrame.Characters
    If .Text = "Small" Then
        .Text = "Full"
    Else
        .Text = "Small"
    End If
End With
End Sub

Open in new window

MacroButton.xlsm
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:Glen Richmond
Comment Utility
Writting this freehand in this window so may need tweaks, but somthign like this called on Button click ..

sub ChangeButton()

  If MyButton.Cation="Small" then 
     MyButton.Cation="Full"
     'do somthign in code here to call the FULL methods.
     Full()
  else
    MyButton.Cation="Small"
     'do somthign in code here to call the SMALL methods.
    Small()
 end if

End Sub

Open in new window

0
 

Author Comment

by:Seamus2626
Comment Utility
RE the correct terminology, i understand now

The toggling is perfect, however, i need the buttons to call the sub as well.

So in the uploaded file i am when "return to excel" is pressed i want sub "small" called, when "Full Screen" is pressed, i want "Full" called

Many thanks
Seamus
Copy-of-MacroButton.xlsm
0
 
LVL 2

Accepted Solution

by:
Glen Richmond earned 250 total points
Comment Utility
just call the subs as i have in my example when the Button click event occurs you call the caption change sub, this handles the call to Small() and Full() too.
0
 

Author Closing Comment

by:Seamus2626
Comment Utility
Thanks Guys!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now