You could always store those columns within a jagged array, an array of arrays. The syntax is actually pretty easy in VBA; you can store all the .Value
s of a range (in the form of an array) inside of another (previously dimmed) array.
When you're working with a range that includes several sub-ranges (contiguous or not), you can access them separately by looping on that range's .Areas
property.
The only thing that you have to be careful about is the indices because the syntax is a little funky and in your particular example you don't start with the first row.
Option Explicit
Sub NonContiguousRanges()
Dim rng As Range
Set rng = Range("C2:C20, G2:G20, J2:J20, T2:T20")
Dim jagged As Variant
ReDim jagged(1 To rng.areas.count)
Dim i As Long
For i = 1 To rng.areas.count
jagged(i) = rng.areas(i).Value2
Next i
'=-~ examples of accessing the values ~-='
'first value, C2
MsgBox jagged(1)(1, 1)
'last value, T20
MsgBox jagged(4)(19, 1)
MsgBox jagged(UBound(jagged))(UBound(jagged(UBound(jagged))), 1)
End Sub
I mean just look at all those UBound
s... gave me a bit of a headache just getting it right!