ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command Button Caption (https://www.excelbanter.com/excel-programming/321773-command-button-caption.html)

Qaspec

Command Button Caption
 
I have a comand button on sheet1. I'd like the caption on the button to
change depending on what is listed in cell a1 on sheet2. Thanks!



Tom Ogilvy

Command Button Caption
 
Use the calculate event for sheet2 if the value will change due to a formula

Right click on the sheet tab and select view code. Then in the resulting
module put in code similar to this.

Private Sub Calculate()
worksheets("Sheet1").CommandButton1.Caption = _
Me.Range("A1").Value
End Sub

If the cell must be manually edited to change then use the Change Event

Private Sub Worksheet_Change(ByVal Target As Range)
worksheets("Sheet1").CommandButton1.Caption = _
Me.Range("A1").Value
End Sub

Chip Pearson's page on events if not familiar with them

http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy

"Qaspec" wrote in message
...
I have a comand button on sheet1. I'd like the caption on the button to
change depending on what is listed in cell a1 on sheet2. Thanks!






All times are GMT +1. The time now is 08:52 AM.

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