Sub 测试()
'
Dim arr(), count
x = Selection.Rows.count
y = Selection.Columns.count
a = Selection.Value
count = 0
ReDim arr(1 To Selection.count)
For i = 1 To x '优先按行
For j = 1 To y
If a(i, j) <> "" Then
count = count + 1
arr(count) = a(i, j)
End If
Next j
Next i
Set tar = Application.InputBox(prompt:="请选择存放结果的单元格(存放不重复序列,按列)。", Title:="结果存放", Type:=8)
If tar Is Nothing Then
Exit Sub
End If
tar.Resize(1, count) = arr '按行写入
End Sub