Archive of Mr Excel Message Board


Back to Controls in Excel archive index
Back to archive home

Caption name = cell value

Posted by Ken on December 27, 2001 8:46 AM
Hi,

I would like to have the caption on a button on a worksheet equal to a cell value, such as "Project 1" input in cell A1, the button face or caption would then read "Project 1". I can use a button from the control toolbox or forms with VBA.

Thank you
Ken


Re: Caption name = cell value

Posted by Jacob on December 27, 2001 10:40 AM
Try this

Private Sub UserForm_Activate()

UserForm1.CommandButton1.Caption = Range("A1").Value

End Sub


Jacob


Re: Caption name = cell value

Posted by Scott on December 27, 2001 10:41 AM
Hi. Not sure if this is the best way, but it works. Put this code in the worksheet section:

Private Function Change_Caption()
CommandButton1.Caption = [A1]
End Function

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Run (Change_Caption())
End Sub

This assumes that A1 is the value that you want to use, and that the name of your button is "CommandButton1".


Thank you Scott, Works great!

Posted by Ken on December 27, 2001 12:49 PM

: Hi, : Ken


This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.