If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > change button properties with variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-04, 08:53
arie ribbens arie ribbens is offline
Registered User
 
Join Date: Jan 2004
Posts: 7
Question change button properties with variables

Does anyone know how i can change the properties of a cmdbutton using variables?
It's hard to explain so i will give you some code...hope it will get clear:

Code:
Dim matrixindex As String
Dim buttonname As String

matrixindex = Sheets("matrix").Cells(1, 1)    
buttonname = "cmd" & matrixindex
         
Worksheets("matrix").buttonname.Caption = "1"
It seems like vba doesn't accept the variable ("buttonname") in that last line of code.

Hope someone can help.

Cheers Arie

Last edited by arie ribbens; 01-27-04 at 10:09.
Reply With Quote
  #2 (permalink)  
Old 02-02-04, 19:52
redma_d redma_d is offline
Registered User
 
Join Date: Jan 2004
Location: Newcastle UK
Posts: 10
I kinda guessing really but is this what ya meant?

D
Attached Files
File Type: zip buttoncaptionchange.zip (8.7 KB, 18 views)
Reply With Quote
  #3 (permalink)  
Old 02-03-04, 17:27
arie ribbens arie ribbens is offline
Registered User
 
Join Date: Jan 2004
Posts: 7
thanks for your reply redma_d, but the code in the attachment is not exactly what i had in mind.
I recently figured it out and if anyone is interested this is the script that worked for me:
Code:
Worksheets("name").OLEObjects(varbuttonname).Object.Caption = "whatever you want"
Cheers,
Arie
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On