I was attempting to use the union property to join a range of cells and take their values all at once, but after going through the code I noticed that myarray only retains the first ranges values( i.e C2:C12).
Sub macro()
Dim myarray() As Variant
Dim myrange As Range
With Worksheets(1)
Set myrange = Application.Union(.Range("C2:C12"), .Range("G2:G12"), _
.Range("J2:J12"), .Range("T2:T12"))
End With
myarray = myrange.Value
End Sub
When I set the values to a range in a worksheet it works just fine, which leads me to believe it can access the values as an array. Is there a reason why this isn't working as I intended? Is there a better way to do this sort of operation?