locked
vba excel filter array RRS feed

  • Question

  • I have been trying to use the filter function on a one dimensional array with little success:

    Here is a piece I have been working on.

    When the msgbox in the middle of the code is used the code does not work and yet when it is commented out the code seems to work. There is something I am not understanding here.

    Sub AAAAtest()

    Dim EntryNo(1 To 5) As String
    Dim SelectedNo() As String
    '
    EntryNo(1) = 1
    EntryNo(2) = 2
    EntryNo(3) = 3
    EntryNo(4) = 4
    EntryNo(5) = 5
    '
    MsgBox EntryNo(3)
    '
    SelectedNo = Filter(EntryNo, 2, False)
    '
    MsgBox SelectedNo(1)
    MsgBox SelectedNo(2)
    '
    MsgBox LBound(SelectedNo, 1)
    MsgBox UBound(SelectedNo, 1)
    '
    End Sub

    Any help would be appreciated. Thanks

    Wednesday, August 24, 2016 4:49 PM

All replies