Dynamic array seems invalid

B

Bas

Hi all,

First of all, I'm a relative newbie when it comes to arrays. I tried
to generate a dynamic array , named 'ClusterValues()' . When I point
my mouse over 'Array(TStV4)' it seems(!) to be a valid array 'saying'
"1, 2, 3" , when I test this array using:

'Application.StatusBar = WorksheetFunction.Index(ClusterValues(), 1,
1)' , the whole array is printed within the status bar, but what wend
wrong?

Thanks in advance!

- Bas


Option Base 1
--
Sub test()

Dim ClusterMembers() As Variant
Dim ClusterValues() As Variant
Dim TBV As Byte
Dim TIV2 As Integer
Dim TIV4 As Integer
Dim TStV4 As String

For TIV4 = 1 To TBV - 1 Step 1
TStV4 = TStV4 & WorksheetFunction.Index(Range("A1").Offset(TIV2,
0).Range("A1:CS1"), 0, WorksheetFunction.Index(ClusterMembers(), 1,
TIV2)) & ", "
Next

TStV4 = TStV4 & WorksheetFunction.Index(Range("A1").Offset(TIV2,
0).Range("A1:CS1"), 0, WorksheetFunction.Index(ClusterMembers(), 1,
TBV))
ClusterValues() = Array(TStV4)

End Sub
 
R

RB Smissaert

Not sure what you need the Index function for.
Have a look at this:

Sub test()

Dim i As Long
Dim c As Long
Dim ClusterValues() As Long

ReDim ClusterValues(1 To 10, 1 To 2)

For i = 0 To 9
For c = 0 To 1
ClusterValues(i + 1, c + 1) = i * 2 + c + 1
Next c
Next i

Application.StatusBar = ClusterValues(3, 2)

Range(Cells(1), Cells(10, 2)) = ClusterValues

End Sub


RBS
 

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

Top