PC Review


Reply
Thread Tools Rate Thread

Commandbutton Caption

 
 
WLMPilot
Guest
Posts: n/a
 
      8th Apr 2008
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
 
Reply With Quote
 
 
 
 
PCLIVE
Guest
Posts: n/a
 
      8th Apr 2008
Maybe using this method.


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


HTH,
Paul

--

"WLMPilot" <(E-Mail Removed)> wrote in message
news:2E7EDE29-2781-49A8-9762-(E-Mail Removed)...
>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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm CommandButton Caption PCLIVE Microsoft Excel Programming 3 29th Jan 2007 11:01 PM
RE: CommandButton Caption Anomily =?Utf-8?B?Sm9obiBCdW5keQ==?= Microsoft Excel Programming 0 29th Dec 2006 10:37 AM
CommandButton Caption kar3n.chandra@googlemail.com Microsoft C# .NET 1 3rd Oct 2006 03:17 AM
CommandButton Caption kar3n.chandra@googlemail.com Microsoft C# .NET 0 29th Sep 2006 08:25 AM
Re: CommandButton.Caption Bob Phillips Microsoft Excel Programming 0 8th Sep 2003 08:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 PM.