N
Nick I
I have an array that can go up to 25 columns and 9 rows in size. I am taking
the contents of this array and placing the data into an Excel sheet through
VB.
Sometimes, however, the array may be only 24 or 23 columns in size since
there is no data in the last few columns. When I run my loop that fills the
data, it kicks out with an error "Subscript out of range".
Instead of getting this error, I would just like the function to place a "0"
in the Excel sheet. Is there a way to tell Access that if I get the
"Subscript out of range" error, to have to go ahead an just put a 0 where I
want?
I tried asking if the array is equal to Null....but apparently subscript out
of range and NULL are not the same thing.
Here is a portion of the code below:
NumberForCell = 0
Down = 0
Across = 2
'Outer loop will be the across loop
For Across = 2 To 25
Down = 0
Letter = LetterReturn(Across + 1)
For Down = 0 To 9
NumberForCell = Down + 14
If IsNull(aryData(Across, Down)) Then
.Cells.Range(Letter & CStr(NumberForCell)) = 0
Else
.Cells.Range(Letter & CStr(NumberForCell)) =
aryData(Across, Down)
End If
Next Down
Next Across
Thanks for your help!
Nick
the contents of this array and placing the data into an Excel sheet through
VB.
Sometimes, however, the array may be only 24 or 23 columns in size since
there is no data in the last few columns. When I run my loop that fills the
data, it kicks out with an error "Subscript out of range".
Instead of getting this error, I would just like the function to place a "0"
in the Excel sheet. Is there a way to tell Access that if I get the
"Subscript out of range" error, to have to go ahead an just put a 0 where I
want?
I tried asking if the array is equal to Null....but apparently subscript out
of range and NULL are not the same thing.
Here is a portion of the code below:
NumberForCell = 0
Down = 0
Across = 2
'Outer loop will be the across loop
For Across = 2 To 25
Down = 0
Letter = LetterReturn(Across + 1)
For Down = 0 To 9
NumberForCell = Down + 14
If IsNull(aryData(Across, Down)) Then
.Cells.Range(Letter & CStr(NumberForCell)) = 0
Else
.Cells.Range(Letter & CStr(NumberForCell)) =
aryData(Across, Down)
End If
Next Down
Next Across
Thanks for your help!
Nick