Select more than on CommandButton

K

K

Hi all, I am trying to select all ComandButtons from 1 to 9 and I
wrote this code (see below) to do this job but I am getting error.
Please can any friend can help that what am I doing wrong.

Private Sub Image1_Click()
Dim i As Integer
For i = 1 To 9
Me.CommandButton&(i).Select
Next
End Sub
 
C

Carim

Hi all,  I am trying to select all ComandButtons from 1 to 9 and I
wrote this code (see below) to do this job but I am getting error.
Please can any friend can help that what am I doing wrong.

Private Sub Image1_Click()
Dim i As Integer
For i = 1 To 9
Me.CommandButton&(i).Select
Next
End Sub

Hi,
Have a go with
Me.Controls("CommandButton" & i).Select

Cheers
 
K

K

Hi,
Have a go with
Me.Controls("CommandButton" & i).Select

Cheers

Hi carim, Thanks for replying. I did try your code but I am still
getting error. Have you got any other suggestions
 
R

Rick Rothstein

Where are your CommandButtons located... on the worksheet or on a UserForm?
If on the worksheet, which toolbar did you get them from... Forms or
Controls Toolbox?

--
Rick (MVP - Excel)


Hi,
Have a go with
Me.Controls("CommandButton" & i).Select

Cheers

Hi carim, Thanks for replying. I did try your code but I am still
getting error. Have you got any other suggestions
 
K

K

Where are your CommandButtons located... on the worksheet or on a UserForm?
If on the worksheet, which toolbar did you get them from... Forms or
Controls Toolbox?

--
Rick (MVP - Excel)






Hi carim,  Thanks for replying.  I did try your code but I am still
getting error.  Have you got any other suggestions- Hide quoted text -

- Show quoted text -

Hi Rick, Thanks for replying. Please see my question which I posted
again to explain what actually I need in link below.
http://groups.google.com/group/micr...ramming/browse_thread/thread/3b37a3e671e0cee5
 
Top