ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Worksheet Button Caption on Worksheet.Activate (https://www.excelbanter.com/excel-programming/378906-change-worksheet-button-caption-worksheet-activate.html)

MikeZz

Change Worksheet Button Caption on Worksheet.Activate
 
Like the title says....
I want to change the text on a worksheet button when I activate the sheet.
I know how to do it in a dialog box but don't have a clue where to start.

In short, I have a list of projects in a column and have a button above the
column.

I have a cell that counts how many projects I list in a range.

I'd like to have the button say something like:
"Summarize X Projects"

where "X" is the count of the projects and gets updated with the correct
quantity whenever I add a project to the list.

Part of my problem is that I have no idea how to find out the name of the
button so I can call it so any resource explaining those kinds of things
would help.

Thanks,

John Green

Change Worksheet Button Caption on Worksheet.Activate
 
It depends. There are two types of command buttons.

For a button created using the Forms toolbar, Ctrl+Click it or Right+Click
it to select it. The name of the button will be in the Name box at the top
left of the screen, where you can change it if you wish. Use code like the
following to change the caption of a button named Button 1 in Sheet1:


Sheet1.Buttons("Button 1").Caption = "XXX"

For a button created with the Control Toolbox toolbar, click the Design Mode
button on the Control Toolbox toolbar to enter design mode. Right+Click the
button and select Properties to see the buttons name and edit it if you
wish. You can then use code like the following to change the caption on a
button named CommandButton1 in Sheet1:

Sheet1.CommandButton1.Caption = "New Test"

John Green

"MikeZz" wrote in message
...
Like the title says....
I want to change the text on a worksheet button when I activate the sheet.
I know how to do it in a dialog box but don't have a clue where to start.

In short, I have a list of projects in a column and have a button above
the
column.

I have a cell that counts how many projects I list in a range.

I'd like to have the button say something like:
"Summarize X Projects"

where "X" is the count of the projects and gets updated with the correct
quantity whenever I add a project to the list.

Part of my problem is that I have no idea how to find out the name of the
button so I can call it so any resource explaining those kinds of things
would help.

Thanks,





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

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