Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with multidimensional arrays (UBound) 1

Status
Not open for further replies.

notuserfriendly

Programmer
May 7, 2004
82
SE
Hi everybody
i've got a problem, I load a sheet into an array
every sheet is indexed 0 to n
every row is then also given an array

Array(index)(index2,index3) according to the debugger
It says that the size of Array(index)(index2) is X
the problem is that I want to loop thru index2
but I can't. What am I doing wrong? Anybody?

I

Code:
For index = 0 To UBound(Obj)
  For index2 = LBound(Obj) To UBound(Obj)
    For index3 = LBound(Obj(index)(index2) To UBound(Obj(index)(index2))
      If StrComp(Obj(index)(index2, index3), VAR) = 0 Then
                        IknewIt = true           
      End If
    Next index3
  Next index2
Next index
 
Have you pressed the F1 key with cursor on the word UBound ?
Why not use a 3-dimensional array instead of an array of 2-dimensional arrays ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

Do you mean when I'm debugging?
If so yes, I get "index out of interval" (translated from swedish)

I do like this when I create the array

Code:
Dim Sheet(5) as Variant
  
LastRow = Find.LastRow

.... sets indexS and indexSheet ...

With Workbooks("YYYY.xls").Worksheets(Cstr(indexS))
   Sheet(indexSheet) = .Range("A2:AQ" + CStr(LastRow))
End With
 
For index = 0 To UBound(Obj)
For index2 = LBound(Obj(index), 1) To UBound(Obj(index), 1)
For index3 = LBound(Obj(index), 2) To UBound(Obj(index), 2)
If StrComp(Obj(index)(index2, index3), VAR) = 0 Then
IknewIt = true
End If
Next index3
Next index2
Next index

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You got a star, it really helped!!!

Thanks a lot, now I will probably be able to sleep :)

I
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top