ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable Array Problem (https://www.excelbanter.com/excel-programming/283615-variable-array-problem.html)

mudraker[_37_]

Variable Array Problem
 

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

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com


Alex J

Variable Array Problem
 
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

"mudraker" wrote in message
...

I have a 1 dimension variable array which I am having problems in
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 97


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/




mudraker[_39_]

Variable Array Problem
 

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


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


Tom Ogilvy

Variable Array Problem
 
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

--
Regards,
Tom Ogilvy



mudraker wrote in message
...

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


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/





All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com