我試圖將多個範圍選擇轉換爲範圍數組。分割範圍包含多個範圍到一個範圍數組中?
眼下這就是我想:
Private Function SplitRange(ByRef r As Range) As Range()
Dim i As Long
Dim RangesArray() As Range
Dim AddressArray() As String
Dim Address As Variant
i = 0
AddressArray = Split(r.Address, ",")
ReDim RangesArray(UBound(AddressArray))
For Each Address In AddressArray
Set RangesArray(i) = Range(Address)
i = i + 1
Next Address
' It works till this point, executing RangesArray(0).Address returns a range address
SplitRange = RangesArray
' Here for some reason neither SplitRange(0).Address or RangesArray(0).Address work
End Function
我如何轉換的「複合型」的範圍爲範圍的數組?
'RangesArray(0).Address'應該工作正常(不適合我)。 'SplitRange(0).Address'將不起作用,因爲它再次調用函數'0'作爲'Range'。 – Rory