|
-
Aug 9th, 2007, 01:19 PM
#1
Thread Starter
Member
[RESOLVED] [Excel] Problem with dynamic arrays
I've got an Excel file I'm working on in which I've got some dynamic arrays I need to use. I have them declared up in Option Explicit, and their size is first defined in my main function.
Code:
Option Explicit
Dim array_temp() As Integer
Dim array_rt() As Integer
Sub DrawSignal()
ReDim array_rt((num_results + 1), (num_results)) As Integer
ReDim array_temp(num_results + 1) As Integer
End Sub
Unfortunately, I need to use them again in multiple functions, but for some reason they keep coming up as Invalid Qualifiers. I've tried using ReDim Preserve to reset the size while still keeping the data, but it's still giving the same error. How can I get it to recognize the arrays?
-
Aug 9th, 2007, 01:47 PM
#2
Fanatic Member
Re: [Excel] Problem with dynamic arrays
When you use Redim Preserve are you trying to adjust more than 1 dimension? I believe only the last dimension can be adjusted. If that's not what you are doing, I think we need more specifics about the error. You might also want to check the values of the your variables just prior to the Redim Preserve statement.
-
Aug 9th, 2007, 05:02 PM
#3
Re: [Excel] Problem with dynamic arrays
you don't need the as integer when you redim
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 13th, 2007, 07:25 AM
#4
Thread Starter
Member
Re: [Excel] Problem with dynamic arrays
Thanks for the replies, but I managed to fix it. Apparently the problem wasn't with the redim at all, but with something else I had overlooked. -_-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|