Variable Array Problem

  • Thread starter Thread starter mudraker
  • Start date Start date
M

mudraker

I have a 1 dimension variable array which I am having problems i
accessing each entry

this is the code I have used to populate the array



dim varImpsArray

varImpsarray = wsImps.UsedRange.Value ' used range = a1 to a 62000


Is their a way of accessing each entry in the array *similar* to the
For Each cell In Range("a1:a3") that applies to spreadsheets


dim ?????? as ????
for each ?????????


I am using Excel 9
 
Mud,

Try a slight variation:

Dim varImpsArray()
varImpsArray = wsImps.UsedRange (I don't think you need ".Value" here)

Your array is a 2 dimension array (that's the way this array read method
works), so:

imax= Ubound(varImpArray,1)
For i =1 to imax
test=varImpArray(i,1)
next i

If you check the locals window in VBE with a break inserted in the program
execution, you will see the structure of varImpsArray.

Hope this helps,
Alex J
 
Alex

Thanks for your reply

I just worked it out


dim varImpsArray as Variant
dim varEntry as Variant

varImpsarray = wsImps.UsedRange.Value
For Each varEntry In varImpsarray
do something
next varEntry
 
dim varImpsArray as Variant
dim i as long

varImpsarray = wsImps.UsedRange.Value
For i = lbound(varImpsarray,1) to ubound(varImpsarray,1)
debug.print varImpsArray(i,1)
Next i
 
Back
Top