ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggling Button Labels Between Expand/Collapse (https://www.excelbanter.com/excel-programming/348118-toggling-button-labels-between-expand-collapse.html)

[email protected]

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!


Dave D-C[_3_]

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 =----


All times are GMT +1. The time now is 10:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com