|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 按钮1_Click()
On Error Resume Next
Sheet2.Range("a3,q100").Clear
Dim arr(), crr() '定义一个动态数组,然后再用"redim"
I = 2
Do While Sheet1.Range("a" & I) <> ""
n = n + 1
ReDim Preserve arr(1 To n) 'Preserve数组随之更新
arr(n) = Join(Application.Transpose(Application.Transpose(Sheet1.Range("a" & I).Resize(1, 17))), "/")
'Transpose将数组转置,通过两次转置成为一维数据,在通过join连接成一个字符串,join只能连接连串的字符或者一维数组
I = I + 1
Loop
brr = Filter(arr, Sheet2.Range("b1").Value)
ReDim crr(1 To UBound(brr) + 1)
For j = 1 To UBound(brr) + 1
k = k + 1
crr(k) = Split(brr(j - 1), "/")
Next
Sheet2.Range("a3").Resize(k, 17) = Application.Transpose(Application.Transpose(crr))
End Sub
|
|