How to create dynamic variable names VBA

后端 未结 2 1740
感动是毒
感动是毒 2020-11-29 10:25

I am trying to create a dynamic number of variables in VBA based on the value in a cell. Essentially what I\'d like to end up with is something like Team1, Team2... to

2条回答
  •  广开言路
    2020-11-29 11:17

    This will get you started. But before you start I recommend watching these WiseOwlTutorials tutorial on Youtube:

    • Selecting Cells (Range, Cells, Activecell, End, Offset)
    • Worksheets, Charts and Sheets
    • Variables
    • Arrays
        Dim i, x As Integer
        x = Range("J4").Value
        Dim Team() As Integer
        Dim Manager() As String
    
        ReDim Team(1 To x) As Integer
        ReDim Manager(1 To x) As String
    
        Range("A3").Select
    
    
        For i = 1 To x
    
            Team(i) = i
    
        Next
    

提交回复
热议问题