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

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

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".



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

Thank you Scott, Works great!

: Hi, : Ken