Solved

Toggle button

Posted on 2014-10-28
7
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 250 total points
ID: 40408503
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
ID: 40408522
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
ID: 40408530
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Glen Richmond
ID: 40408559
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
ID: 40408588
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
ID: 40408640
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
ID: 40408801
Thanks Guys!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

735 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