Search code examples
arraysvbavariant

VBA Array variable


The following code works well if I use n as a Variant but gives me "Run time error 13 Type mismatch" if I dim n as Integer. Are there any downsides to using the Variant? Any other suggestions?

Sub Update_Yest()

    Dim tbl As ListObject
    Dim n() As Variant

    n = Array(10, 13, 17, 20, 28, 31, 35, 38)

    For i = 0 To UBound(n)
        Debug.Print n(i)
    Next i

End Sub

Solution

  • No downside, used n as variant