ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array Empty After Sub Called (https://www.excelbanter.com/excel-programming/324263-array-empty-after-sub-called.html)

ExcelMonkey[_190_]

Array Empty After Sub Called
 
I have a public 1D array.

Public Array1 as Variant

I have loaded it with text strings.

Array1(0) = "Comment"
Array1(1) = "Range"
etc

After loading it, I Debug.Print Array(0) etc and it shows
that the array has text strings in it. I can also search
the array with an application.Index function and return
the strings.

However right after I call a new sub, the array is
empty. This is odd as it was declared as public and I
have other arrays in the same sub with integers which
make their way to the sub that his one is failing in.

Anybody know why this would happen?

Thanks

Tom Ogilvy

Array Empty After Sub Called
 
the first thing that comes to mind is in the sub where it fails, you have a
duplicate name declared. This local variable takes precedence and contains
no data.

--
Regards,
Tom Ogilvy

"ExcelMonkey" wrote in message
...
I have a public 1D array.

Public Array1 as Variant

I have loaded it with text strings.

Array1(0) = "Comment"
Array1(1) = "Range"
etc

After loading it, I Debug.Print Array(0) etc and it shows
that the array has text strings in it. I can also search
the array with an application.Index function and return
the strings.

However right after I call a new sub, the array is
empty. This is odd as it was declared as public and I
have other arrays in the same sub with integers which
make their way to the sub that his one is failing in.

Anybody know why this would happen?

Thanks




ExcelMonkey[_190_]

Array Empty After Sub Called
 
Yeah thats what I thought to but doesn't seem to be the
case. Have reposted with detail.

Thanks for all you help Tom. Been living off every word
for last several days.


-----Original Message-----
the first thing that comes to mind is in the sub where it

fails, you have a
duplicate name declared. This local variable takes

precedence and contains
no data.

--
Regards,
Tom Ogilvy

"ExcelMonkey" wrote

in message
...
I have a public 1D array.

Public Array1 as Variant

I have loaded it with text strings.

Array1(0) = "Comment"
Array1(1) = "Range"
etc

After loading it, I Debug.Print Array(0) etc and it

shows
that the array has text strings in it. I can also search
the array with an application.Index function and return
the strings.

However right after I call a new sub, the array is
empty. This is odd as it was declared as public and I
have other arrays in the same sub with integers which
make their way to the sub that his one is failing in.

Anybody know why this would happen?

Thanks



.



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

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