Reputation: 873
Can I do this?
For i = 1 To 127
Dim cell&i as Range
Next
Because I have a lot of cells need to dim.
Upvotes: 0
Views: 33
Reputation: 38540
No, you can't.
Try using an array instead:
Dim nCells As Long
Dim myCells() As Range 'store them in an array
nCells = 127
ReDim myCells(1 To nCells)
For i = 1 To nCells
Set myCells(i) = Range("A1").Offset(i,i) ' or whatever...
Next i
Maybe you should show us what you are trying to achieve exactly. This pattern looks a bit unusual.
Upvotes: 1