View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson[_2_] Chip Pearson[_2_] is offline
external usenet poster
 
Posts: 95
Default Variable Button Name based on Data? Can it be done?

John,

Try something like the following:

Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
WS.OLEObjects("CommandButton1").Object.Caption = "New Text"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"John Baker" wrote in message
...
Chip:

Either that doesn't work for me, or Iam too much of a newby to understand

your suggestion.
I set up a macro with the line you gave me, changing the names to my sheet

name and
command button, and making the source of the name a variable containing

the name I
wanted..Thus:

Sub test()
'
' test Macro
' Macro recorded 11/21/2003 by John H Baker
Sheets("datefunction").Select
Range("f2").Select
ActiveCell() = but6
Sheets("Input").Select
Sheets("input").CommandButton6.Caption = but6
'
End Sub

The only result appears to be to blank out the data in datefunction!F2!

Can you give me just a tad more guidance?

Regards

John Baker






"Chip Pearson" wrote:

John,

I assume you are using the Command Buttons from the Controls toolbar, not
the Forms toolbar. Given that, you can change the Caption property of

the
button to the new text. E,g.,

Sheet1.CommandButton1.Caption = "New Text"