Commandbutton Caption

W

WLMPilot

I have 26 commandbuttons on Sheet2. I created each by copy & paste. This
caused the caption to be Commandbutton1 on all 26. I thought the following
code would change each, but it is not working. I get the following error and
the "&" sign is highlighted:

Compile Error Expected: expression

Here is the code:

Private Sub CommandButton27_Click()
Worksheets("Sheet2").Active
For k = 2 To 26
Commandbutton & k.Caption = "Commandbutton"&k
End Sub

Les
 
P

PCLIVE

Maybe using this method.


For k = 2 To 26
ActiveSheet.OLEObjects("Commandbutton" & (k)).Object.Caption =
"Commandbutton" & k
Next


HTH,
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top