Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    7

    Question Unanswered: 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 11:09.

  2. #2
    Join Date
    Jan 2004
    Location
    Newcastle UK
    Posts
    10
    I kinda guessing really but is this what ya meant?

    D
    Attached Files Attached Files

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •