Using VBA to assign range of cell values to array of variables

前端 未结 3 1103
迷失自我
迷失自我 2021-01-05 16:47

I\'m very new to VBA, to bear with me here.

I want to assign a set of variables the value of a set of ranges ie. run a brief code to simplify the following



        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 17:12

    You should :

    • Define the range you want to retrieve data
    • For each cell of the range, retrieve your datas

      dim tab() As string, cell as range, i as integer
      i = 0
      redim tab(0)
      for each cell in ActiveWorksheet.Range("C1:C20")
          tab(i) = cell
          i = i + 1
          redim preserve tab(i)
      next
      

    edit : I indent the code to display it correctly

提交回复
热议问题