blukrr
02-07-2013, 06:03 AM
Hello folks,
I would like to do basically what the title says: Change object properties for previously created objects.
I have a table in column A of a worksheet named Codes full of itens, lets say:
120
121
122
123
I also have buttons named Button120, Button121, Button122 and Button123.
I made this code that does a FOR for each button in the table above.
Now I need to pass the button name so that it will change the button I should be changing the propeties every time the FOR loops.
Something like this.
TotalData = Worksheets("Codes").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
For i = 1 To TotalData
CurrentBut = "Button" & Worksheets("Codes").Cells(i, "A").Value
With CurrentBut
.Enabled = False
.Caption = CurrentBut
End With
Next i
But somehow this code won't work because I can't assign the With function a variable object.
is there a way of doing this?
Thanks in advance or any tips.
I would like to do basically what the title says: Change object properties for previously created objects.
I have a table in column A of a worksheet named Codes full of itens, lets say:
120
121
122
123
I also have buttons named Button120, Button121, Button122 and Button123.
I made this code that does a FOR for each button in the table above.
Now I need to pass the button name so that it will change the button I should be changing the propeties every time the FOR loops.
Something like this.
TotalData = Worksheets("Codes").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
For i = 1 To TotalData
CurrentBut = "Button" & Worksheets("Codes").Cells(i, "A").Value
With CurrentBut
.Enabled = False
.Caption = CurrentBut
End With
Next i
But somehow this code won't work because I can't assign the With function a variable object.
is there a way of doing this?
Thanks in advance or any tips.