Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default trouble assigning array to variable (variant) runtime error 9 please help (ignore correction, this didn't appear for some reason)

Hi,

I have a piece of code that:

Redims an array
Collects variables to fill it
assigns the array to a variable publicly declared as a variant

I am at a loss as this system works fine for me throughout the project but
in this instance throws up the error (Runtime 9 as in in the subject line of
this post) and will not fill the variable. Since the use of it seems
identical to other procedures throughout the workbook (and it works fine
there), I cannot for the life of me figure out why it has decided to stop
working here.

I have added watches for both arrays, and they both contain what they
should, but the second procedure fails at then end on the last line:

pvarrThatDoesntWork = parrCallbacksDueToday()

Why I have no idea at all. If anyone has any ideas I would be most grateful.
Below is a procedure in which it works followed by the one that
(inexplicably) doesn't. I am sure it's blindingly obvious and I will feel
like a klutz (hope so:).

Thanks in advance, regards, Mark



WORKS

Public pvarrThatWorks As Variant


Sub ProcedureThatWorks

Dim iCol As Integer


ReDim parrArray1 (10, 20)


For i Row = 1 To 10

'This fills the array
For iCol = 1 To 20

parrArray1 (iRow, iCol) =
Sheets("Database").Cells(iRow, iCol).Value

Next iCol

Next piRowInMainDatabase


pvarrThatWorks = parrArray1 ()


End Sub



DOESN'T WORK

Public pvarrThatDoesntWork As Variant

Sub ProcedureThatDOESNOTwork()

Dim iCol As Integer



'Creates an array containing Time and row number in main database which is
then searched to get the earliest for loading into the GUI, is added to each
time a new Callback is added for today
ReDim parrArray2 (10, 2)


For i Row = 1 To 10

parrArray2 (iRow,1) = Sheets("Database").Cells(iRow, 1).Value
parrArray2 (iRow,2) = iRow


Next i Row

pvarrThatDoesntWork = parrCallbacksDueToday()

End Sub








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
Correction to previous post re runtime error 9 mark Stephens Excel Programming 0 July 26th 09 04:39 PM
Runtime error 9 subscript out of range - assigning array to variable mark Stephens Excel Programming 0 July 26th 09 04:20 PM
Runtime error 13-- Setting a variant Range?! [email protected] Excel Programming 3 September 11th 06 07:03 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Runtime error 91 when assigning range katarakt Excel Programming 1 April 24th 05 01:47 PM


All times are GMT +1. The time now is 07:00 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"