'自定义公式-按ALT+11-插入-模块(合并)
Function 合并(a As Integer, b As String)
Dim arr(1 To 20000, 1 To 1)
For i = 2 To 10000
If Sheets("A").Cells(i, a) = "" Then Exit For
n = n + 1
arr(n, 1) = Sheets("A").Cells(i, a)
Next
For i = 2 To 10000
If Sheets("B").Cells(i, a) = "" Then Exit For
n = n + 1
arr(n, 1) = Sheets("B").Cells(i, a)
Next
For i = 2 To 10000
If Sheets("C").Cells(i, a) = "" Then Exit For
n = n + 1
arr(n, 1) = Sheets("C").Cells(i, a)
Next
For i = 2 To 10000
If Sheets("D").Cells(i, a) = "" Then Exit For
n = n + 1
arr(n, 1) = Sheets("D").Cells(i, a)
Next
合并 = arr(b, 1)
If 合并 = "" Or 0 Then 合并 = ""
End Function