Looping through an array

szita2000

Board Regular
Joined
Apr 25, 2012
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Hi Guys, and Happy New Year to everybody!

I am trying to build something like a widget.
I created shapes that are named in this fashion: A01_TrafficLight, A02_TrafficLight, B03_TrafficLight etc...

I have the corresponding list of names in a named range on a sheet ie: A01, A02, B03...
How can I loop though the of names corresponding to my shapes naming convention to do something to the shape name?

I want to concatenate the shape name from a table of all the names. So I can refer to it. (There are other shapes for each machine named A01_Title, A01_TextBox and so on...)

One way I can think of (but it's not elegant) :) if I start like this then I can use an integer to loop through the number

VBA Code:
Dim xMachine(1 To 17) As String
    
    xMachine(1) = "A01"
    xMachine(2) = "A02"
    xMachine(3) = "B03" 'and so on...

What I really want is that the Setting of the Array to be dynamic.
I have the names of my machines on Sheet4 in a named range named rngMachineList

Is there any way to do this?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Something like:

VBA Code:
Dim xMachine As Variant
xMachine = Sheet4.Range("rngMachineList").Value


You can then loop through xMachine
 
Upvote 0
Something like:

VBA Code:
Dim xMachine As Variant
xMachine = Sheet4.Range("rngMachineList").Value


You can then loop through xMachine
Thanks Kyle!
In the meantime I watched a tutorial on Arrays and how to declare them. Thanks for the help though!
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top