Looping A Variable Used Within An Object Name

  • Thread starter Thread starter Tommy
  • Start date Start date
T

Tommy

Hi guys,

Simple bit of code:

For c = 2 To Nofcharts

With Worksheets(SheetName)
Set ZoomArray(c) = .Zoom & c
End With

Next c

What I want to do is to be able to loop through a number of objects
(they are toggle buttons) called Zoom2, Zoom3, Zoom4 etc. Obviously
the code above doesn't work, so how can I modify it so that it is able
to set e.g. ZoomArray(5) = .Zoom5

Thanks and regards,

Tom
 
Sub Test()
Dim X As Integer
Dim Arr(1 To 4) As Shape
For X = 1 To 4
Set Arr(X) = Sheet1.Shapes("Zoom" & X)
Next
End Sub


--
Jim
| Hi guys,
|
| Simple bit of code:
|
| For c = 2 To Nofcharts
|
| With Worksheets(SheetName)
| Set ZoomArray(c) = .Zoom & c
| End With
|
| Next c
|
| What I want to do is to be able to loop through a number of objects
| (they are toggle buttons) called Zoom2, Zoom3, Zoom4 etc. Obviously
| the code above doesn't work, so how can I modify it so that it is able
| to set e.g. ZoomArray(5) = .Zoom5
|
| Thanks and regards,
|
| Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top