Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Concatenating string and variable to reference another variable

$
0
0

Is it possible to combine a string and a variable to create a name of another variable and referencing it in the same go? Like this:

Sub Test()
    Dim colorName As String
    Dim columnYellow As Long

    colorName = "Yellow"
    columnYellow = 3

    Debug.Print columnYellow '-> prints "3"
    Debug.Print "column"& colorName '-> prints "columnYellow" (I would like it to return 3)

End Sub

I would want Debug.Print "column"& colorName to return "3" instead of "columnYellow". Ho can I do that?


Viewing all articles
Browse latest Browse all 88835

Trending Articles