Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Array handling error

Hi

It's not easy to make good suggestions when you can't see your full
code, but have you ReDimensioned the YearD() dynamic array prior to
attempting to place values in it?

Best regards

Richard


PALysiak wrote:
I am trying to extract all of the column 9 data in the GoodArray(), earlier
in the program it is filled with data (I checked the locals window, it is
dimensioned properly and filled with what I want). When I go to take the data
from cell or column 9 from a 2 dimensional array and do a "Left" operation on
the data string in the cell and put it in a 1 dimensional array, I get an
"Out of Range" error. I added the "Dummy" variable to see if the Left
function worked and it does. It just refuses to take the column in a two
dimensional array and put it into a one dimensional array. What am I doing
wrong?


Dim YearD() as variant
Dim A As String
Dim Dummy as String

Dummy = GoodArray(9, i)
A = Left(Dummy, 2)


YearD(i) = Left(Dummy, 2) 'Extract the year
YearD(i) = Right(YearD(i), 1)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Array handling error

Because you dimmed it as a dymanic array, but didn't assign any dimensions.
Now you use redim to assign the dimensions.

--
Regards,
Tom Ogilvy

"PALysiak" wrote in message
...
Yes, I believe that works.
If I had just Dim the variable a few lines before, why would I redim then?
Thanks very much for your quick response.

"RichardSchollar" wrote:

Hi

It's not easy to make good suggestions when you can't see your full
code, but have you ReDimensioned the YearD() dynamic array prior to
attempting to place values in it?

Best regards

Richard


PALysiak wrote:
I am trying to extract all of the column 9 data in the GoodArray(),
earlier
in the program it is filled with data (I checked the locals window, it
is
dimensioned properly and filled with what I want). When I go to take
the data
from cell or column 9 from a 2 dimensional array and do a "Left"
operation on
the data string in the cell and put it in a 1 dimensional array, I get
an
"Out of Range" error. I added the "Dummy" variable to see if the Left
function worked and it does. It just refuses to take the column in a
two
dimensional array and put it into a one dimensional array. What am I
doing
wrong?


Dim YearD() as variant
Dim A As String
Dim Dummy as String

Dummy = GoodArray(9, i)
A = Left(Dummy, 2)


YearD(i) = Left(Dummy, 2) 'Extract
the year
YearD(i) = Right(YearD(i), 1)





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Array handling error

Obviously I am a rookie to this stuff.
When I dimmed it with () or empty array I thought I was assigning the
variable a dynamic array. Redimming does work.

Again thanks for your help, this was driving me nuts.

"Tom Ogilvy" wrote:

Because you dimmed it as a dymanic array, but didn't assign any dimensions.
Now you use redim to assign the dimensions.

--
Regards,
Tom Ogilvy

"PALysiak" wrote in message
...
Yes, I believe that works.
If I had just Dim the variable a few lines before, why would I redim then?
Thanks very much for your quick response.

"RichardSchollar" wrote:

Hi

It's not easy to make good suggestions when you can't see your full
code, but have you ReDimensioned the YearD() dynamic array prior to
attempting to place values in it?

Best regards

Richard


PALysiak wrote:
I am trying to extract all of the column 9 data in the GoodArray(),
earlier
in the program it is filled with data (I checked the locals window, it
is
dimensioned properly and filled with what I want). When I go to take
the data
from cell or column 9 from a 2 dimensional array and do a "Left"
operation on
the data string in the cell and put it in a 1 dimensional array, I get
an
"Out of Range" error. I added the "Dummy" variable to see if the Left
function worked and it does. It just refuses to take the column in a
two
dimensional array and put it into a one dimensional array. What am I
doing
wrong?


Dim YearD() as variant
Dim A As String
Dim Dummy as String

Dummy = GoodArray(9, i)
A = Left(Dummy, 2)


YearD(i) = Left(Dummy, 2) 'Extract
the year
YearD(i) = Right(YearD(i), 1)





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Handling ubound on an uninitialised array Mike NG Excel Programming 14 January 24th 05 09:05 AM
error handling off?? Tom Ogilvy Excel Programming 0 August 19th 04 04:31 PM
Error handling Tim C Excel Programming 1 October 7th 03 10:00 PM


All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"