Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Somehow my previous answer and msg was lost, that's why I post this again. I want to write some universal code to process arrays. The number of arrays can change per project. So I wrote the next piece of code. First I count the needed arrays and put the outcome in a variable. Using a counter and a loop I want to repeat an action on each of the arrays by creating the name of the array and then process it. But substituting the variable to use it as the name of the array doesn't work. The question is how I can get the value in the variable to work as a NAME for the array. Sub WorkWithArray() Dim Arr1 As Variant Dim Arr2 As Variant Dim strArrName Dim strArrNr Dim intArrCount ' Fill two arrays Arr1 = Array("A", "B") Arr2 = Array("C", "D") ' Fill counters and create the first name for the array strArrNr = 1 intArrCount = 2 strArrName = "Arr" & Nr ' Nr = 1, so strArrName = "Arr1" ' Repeat doing something with each of the arrays For intArrNr = 1 To intArrCount Msgbox strArrName(1) ' But THIS doesn't work. How do I get ' the CONTENT in the variable work as the Array-designation ' so that it says or acts like ' Msgbox Arr1(1) strArrNr = strArrNr + 1 strArrName = "Arr" & Nr Next End sub Rob |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dim an Array with a variable | Excel Programming | |||
Array & variable | Excel Programming | |||
how can I see if an array contain a certain variable? | Excel Programming | |||
about ARRAY variable | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |