Results 1 to 4 of 4

Thread: [RESOLVED] [Excel] Problem with dynamic arrays

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    Resolved [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?

  2. #2
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  4. #4

    Thread Starter
    Member
    Join Date
    Apr 2005
    Location
    Arlington, TX
    Posts
    60

    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
  •  



Click Here to Expand Forum to Full Width