Hi Chip
An earlier post appeared to work, however I found that when I edited other
cells in the worksheet the commandbutton would be updated, no idea how when I
had specified the target cell
Anyway, I tried what you suggested:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Const SHEET_WITH_BUTTON = "Setup" <<NAME OF SHEET CONTAINING BUTTON
Const SHEET_WITH_CHANGE_CELL = "Sheet1" '<<< NAME OF SHEET WITH CELL
Const CHANGE_CELL_ADDRESS = "$B$1" '<<< CELL REFERENCE
Const BUTTON_NAME = "CommandButton1" '<<< COMMANDBUTTON NAME
If StrComp(Sh.Name, SHEET_WITH_CHANGE_CELL, vbTextCompare) = 0 Then
If Target.Address = CHANGE_CELL_ADDRESS Then
Me.Worksheets(SHEET_WITH_BUTTON).OLEObjects(BUTTON _NAME). _
Object.Caption = Target.Text
End If
End If
End Sub
I must be still missing something because nothing happens when I change cell
value on sheet1!B1
Thanking you in advance for your support.
Regards
Tanya
"Chip Pearson" wrote:
Tanya,
Paste the following code in the ThisWorkbook module.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Const SHEET_WITH_BUTTON = "Sheet1" '<<< CHANGE.
Const SHEET_WITH_CHANGE_CELL = "Sheet2" '<<< CHANGE
Const CHANGE_CELL_ADDRESS = "$A$1" '<<< CHANGE
Const BUTTON_NAME = "Button1" '<<< CHANGE
If StrComp(Sh.Name, SHEET_WITH_CHANGE_CELL, vbTextCompare) = 0 Then
If Target.Address = CHANGE_CELL_ADDRESS Then
Me.Worksheets(SHEET_WITH_BUTTON).OLEObjects(BUTTON _NAME). _
Object.Caption = Target.Text
End If
End If
End Sub
Change the value of SHEET_WITH_BUTTON to the name of the worksheet on which
the command button resides.
Change the value of SHEET_WITH_CHANGE_CELL to the name of the worksheet
containing the cell whose text you want to assign to the button.
Change CHANGE_CELL_ADDRESS to the address of the cell that triggers the
change of the button's caption. The '$' characters are required as shown.
Change BUTTON_NAME to the name of the button whose text is to change.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"Tanya" wrote in message
...
Hi
Is it possible to have the description/label of a command button updated
by
the title in a sheet cell?
cheers
Tanya