为
EXCEL 365
我想让公式产生:
我可以用“半动态”来实现:
=IF(ROWS($1:1)>COUNTA(A:A)+COUNTA(C:C),"",IF(ROWS($1:1)<COUNTA(A:A)+1,INDEX(A:A,ROWS($1:1)),INDEX(C:C,ROWS($1:1)-COUNTA(A:A))))
只是
INDEXs
指数
下到第二列。
-
它是动态的,在这个意义上,输出会调整以添加/删除列中的项
或
B
-
它是手动的,因为它必须被手动向下复制,而不是自己溢出
我可以使用VBA获得所需的行为:
Option Explicit
Public Function stack2(r1 As Range, r2 As Range) As Variant
Dim c1 As Long, c2 As Long, r As Range, temp
Dim i As Long
c1 = r1.Count
c2 = r2.Count
ReDim temp(1 To c1 + c2, 1 To 1)
i = 1
For Each r In r1
temp(i, 1) = r.Value
i = i + 1
Next r
For Each r In r2
temp(i, 1) = r.Value
i = i + 1
Next r
stack2 = temp
End Function
但我需要一个公式而不是VBA。我可以检索到一个单独的列并将其溢出:
=INDEX(A:A,SEQUENCE(COUNTA(A:A)))
有什么想法吗??