此VBA合并范围功能在Windows中有效,但在Mac OS中为#VALUE
。
Option Explicit
Public Function MergeRange(ParamArray rng()) As Single()
Dim i As Long
Dim count As Long
Dim r As Excel.Range
Dim s() As Single
For i = LBound(rng) To UBound(rng)
If (TypeOf rng(i) Is Excel.Range) Then
For Each r In rng(i)
ReDim Preserve s(count)
s(count) = r.Value
count = count + 1
Next r
End If
Next i
MergeRange = s
End Function
代码来自另一个stackoverflow线程How merge/mix range of cell as formula parameter