+ Reply to Thread
Results 1 to 7 of 7

Toggling Button Labels Between Expand/Collapse

  1. #1

    Toggling Button Labels Between Expand/Collapse

    Hi. I'm new to VBA and stuck on what I thought would be a simple task.
    I have a worksheet with several large sections arranged vertically.
    Each section has a header with a button control next to it. I'd like
    to have the user click the button to toggle between hiding/showing
    several rows below it and at the same time toggle the text label of the
    button between Expand and Collapse.

    I found the button property I need to toggle
    (Selection.Characters.Text), but I'm not sure of the best way to
    declare some sort of "binary toggle" variable and then step back and
    forth between the two.

    Any advice? Thanks!


  2. #2
    Dave D-C
    Guest

    Re: Toggling Button Labels Between Expand/Collapse

    How about:
    If CommandButton1.Caption = "Expand" then
    Range(xx).Show
    CommandButton1.Caption = "Collapse"
    else
    Range(xx).Hide
    CommandButton1.Caption = "Expand"
    End If

    thomas wrote:
    >Hi. I'm new to VBA and stuck on what I thought would be a simple task.
    > I have a worksheet with several large sections arranged vertically.
    >Each section has a header with a button control next to it. I'd like
    >to have the user click the button to toggle between hiding/showing
    >several rows below it and at the same time toggle the text label of the
    >button between Expand and Collapse.
    >I found the button property I need to toggle
    >(Selection.Characters.Text), but I'm not sure of the best way to
    >declare some sort of "binary toggle" variable and then step back and
    >forth between the two.



    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

  3. #3
    Registered User
    Join Date
    06-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Exclamation Re: Toggling Button Labels Between Expand/Collapse

    Hi, I am a bit of a novice in trying to develop a +/- button to each main heading of a comprehensive form. I would like to have these buttons on the actual spreadsheet (which will be protected)to hide rows below each heading in an expand/collapse format, a function which is already available in Data/Group, that I don't want to use. I've checked previous posts and tried to copy and paste the code in an Excel spreadsheet but each time there is an error during runtime. Is there someone who could send me a sample spreadsheet to end my frustration. The aim is as follows:

    (+/- button) Heading 1
    Question 1
    Question 2

    (+/- button) Heading 2
    Question 1
    Question 2
    Question 3

    Thanks

    Tasdan

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Toggling Button Labels Between Expand/Collapse

    Tasdan,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Registered User
    Join Date
    06-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Toggling Button Labels Between Expand/Collapse

    Apologies, Arlu. Still trying to find the post new thread button or hyperlink.

    Thanks

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Toggling Button Labels Between Expand/Collapse

    Click on the sub-forum where you want to post your question. You will find a button saying Post New Thread at the top. Click that and proceed.

  7. #7
    Registered User
    Join Date
    06-25-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Toggling Button Labels Between Expand/Collapse

    Cheers, Arlu Am now finding my way around the forum

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1