using variable for array substitution

  • I have to arrays UF1() and UF2()


    I have dim'ed them


    dim UF1(), UF2()


    I want to access them with a variable.


    Eg:


    x = 1
    arrname = "UF" & x (arrname will = UF1 or UF2)


    then use it below as such


    redim preserve arrname( 1 to some number)


    Is this possible?


    I know you can do this with userform objects. Eg: set obj = me.controls("label" & x)

  • No, it's impossible
    maybe something like this

    Code
    If x = 1 Then
        ReDim Preserve UF1(1 To 5)
    Else
        ReDim Preserve UF2(1 To 5)
    End If
  • thanks Nilem. I thought so. but I asked anyway.


    I already have what I need working as a single array. I wanted to split it into to arrays, (one for each userform) but did not want the extra redundant code.


    Here's my code


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!