+ Reply to Thread
Results 1 to 3 of 3

Thread: redim preserve error

  1. #1
    Registered User
    Join Date
    01-17-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    redim preserve error

    I receive the error: array already dimensioned, when running the following code:

    Private Sub check_QREF(i As Integer, j As Long)
    
        If IsEmpty(Worksheets(GS_ANNEX_WS).Cells(i, j)) Then
            
            missingQrefs(1, n) = i
            missingQrefs(2, n) = j
            
            n = n + 1
            ReDim Preserve missingQrefs(1 To 2, 1 To n)
            MsgBox n
        End If
    
    'MsgBox "checked in row" & missingQrefs(1, n) & " in column " & missingQrefs(2, n)
    
    End Sub
    the array and the counter n is dimensioned as public, in the Declaration part of the code:
    Dim n As Long
    Dim missingQrefs(1 To 2, 1 To 1) As Long
    And the sub check_qref is called by another sub with the row and column number of the cell where the qref is expected to be. in that sub n is initialized to 1.
    Last edited by ggabi; 02-08-2012 at 01:59 AM.

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: redim preserve error

    An array declared with subscripts is static. A dynamic array is declared with empty parens.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    01-17-2012
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: redim preserve error

    Thanks a lot!!!! - I imageined something much more complicated. :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0