Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Commandbutton Caption

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Commandbutton Caption

Maybe using this method.


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


HTH,
Paul

--

"WLMPilot" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CommandButton Caption Anomily John Bundy Excel Programming 0 December 29th 06 10:37 AM
Commandbutton caption change peter.thompson[_6_] Excel Programming 6 December 22nd 05 06:29 AM
Caption disappears from CommandButton. Ed Excel Programming 0 April 19th 05 09:23 PM
Change CommandButton Caption Claude Excel Programming 4 July 16th 04 04:18 PM
CommandButton.Caption Bob Phillips[_5_] Excel Programming 0 September 8th 03 08:15 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"