Is there a way to simplify this VBA
>>> use code - tags <<<
>>> use code - tags <<<
Code:
Dim myRange As Range: Set myRange = Worksheets(1).ListObjects(1).ListColumns(1).DataBodyRange
Dim myRange1 As Range: Set myRange1 = Worksheets(1).ListObjects(1).ListColumns(2).DataBodyRange
Dim myArray As Variant: myArray = IIf(myRange.Rows.Count = 1, Array(myRange), Application.Transpose(myRange))
Dim myArray1 As Variant: myArray1 = IIf(myRange1.Rows.Count = 2, Array(myRange1), Application.Transpose(myRange1))
Dim Y As Long
For Y = LBound(myArray) To UBound(myArray): Range("B3").Value = myArray(Y)
Next
For Y = LBound(myArray1) To UBound(myArray1): Range("C3").Value = myArray1(Y)
Next
Last edited by a moderator: