|
本帖最后由 嘿嘿嘿哈嘿 于 2024-3-26 16:17 编辑
- Sub 合并数据()
- Dim ws As Worksheet, arr
- Dim i&, j&, p&, rng As Range
- Sheets(1).UsedRange.ClearContents
- Sheets(2).[A1:I2].Copy Sheets(1).[A1]
- For Each ws In Worksheets
- If IsEmpty(ws.[A5]) = False Then
- If ws.Name <> "汇总" Then
- Set rng = ws.[A1:I100].SpecialCells(xlCellTypeConstants, 3)
- arr = rng
- For j = 3 To UBound(arr)
- i = i + 1
- Sheets(1).Cells(i + 2, 1) = i
- For p = 2 To UBound(arr, 2)
- Sheets(1).Cells(i + 2, p) = arr(j, p)
- Next p
- Next j
- End If
- End If
- Next
- End Sub
复制代码 问题出现在9/10行,我是想把筛选之后rng直接赋值给一个数组,可是一直出问题,arr里面只有一个单元格数据。specialcells返回的是range类型的数据吗?为什么不能直接赋值给数组呀?真诚提问各位大佬
|
|