PDA

View Full Version : Reassign variable



clvestin
02-14-2007, 09:07 AM
I must assign some chart titles from names in an array.
The particular array of names depends on a selection from a listbox.

coldata0 = Array("c", "d", "e", "f", "g", "h", "i", "j", "k")
coldata1 = Array("c", "d", "f", "g")
coldata2 = Array("c", "d", "f", "g")
coldata3 = Array("c", "g", "e", "f")
coldata4 = Array("c", "c", "x", "z")
coldata5 = Array("c", "c", "x", "z")

Then
If m = 0 Then coldata = coldata0
If m = 0 Then namdata = namdata0

If m = 1 Then coldata = coldata1
If m = 1 Then namdata = namdata1

If m = 2 Then coldata = coldata2
If m = 2 Then namdata = namdata2

If m = 3 Then coldata = coldata3
If m = 3 Then namdata = namdata3

If m = 4 Then coldata = coldata4
If m = 4 Then namdata = namdata4

If m = 5 Then coldata = coldata5
If m = 5 Then namdata = namdata5

However, i've trie a statement like

coldata = "coldata" & m
whereupon i produce the string "coldata1", eg.
Syntactically, I'm missing something. In the immediate window i can easily reassign usingcoldata = coldata3
and all is well(I can locate by index and all).I've tried a number of the conversion functions(cvar, cstr) but to no avail.

Bob Phillips
02-14-2007, 10:25 AM
Dim coldata(0 To 5)
Dim m As Long
Dim coldatum

coldata(0) = Array("c", "d", "e", "f", "g", "h", "i", "j", "k")
coldata(1) = Array("c", "d", "f", "g")
coldata(2) = Array("c", "d", "f", "g")
coldata(3) = Array("c", "g", "e", "f")
coldata(4) = Array("c", "c", "x", "z")
coldata(5) = Array("c", "c", "x", "z")

m = InputBox("value between 0 and 5")
coldatum = coldata(m)