Copy Multiple Non-Adjacent Columns To Array
问题 I'm trying to copy multiple non-adjacent (non-contiguous) excel columns to an array but it's not working. Below is what I've tried... Public Function Test() Dim sh As Worksheet: Set sh = Application.Sheets("MyWorksheet") Dim lr As Long: lr = sh.Cells(sh.Rows.Count, 1).End(xlUp).row Dim r1 As Range: Set r1 = sh.Range("A1:A" & lr) Dim r2 As Range: Set r2 = sh.Range("C1:C" & lr) Dim rAll As Range: Set rAll = Union(r1, r2) 'Dim arr() As Variant: arr = Application.Transpose(rAll) <-- Throws Type