[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Toggle button

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
Seamus2626
Asked:
Seamus2626
  • 3
  • 2
  • 2
2 Solutions
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
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
 
Seamus2626Author Commented:
Well, the buttons are from the developer tab and activating VB code on pressing them, so its both excel and VB

Thanks
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Glen RichmondCustomer Reporting Programmer.Commented:
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
 
Seamus2626Author Commented:
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
 
Glen RichmondCustomer Reporting Programmer.Commented:
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
 
Seamus2626Author Commented:
Thanks Guys!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now