|
改进版本,50000行96列,38秒已经很不错了- Sub aaa() '假设从本目录"数据文件.xlsx"工作簿"Sheet1"的"A:CS"列取值
- t = Timer
- Dim i As Long
- Dim arr As Variant
- Sheet2.Cells.Clear 'Sheet2为临时工作表
- Path = ThisWorkbook.Path
- WorkbookName = "数据文件.xlsx"
- SheetName = "Sheet1"
- i = 50000
- RangeName = "a1:CS" & i
- bbb Path, WorkbookName, SheetName, RangeName
- Sheet1.Range(RangeName).Clear
- arr = Sheet2.Range(RangeName).Value
- '''Sheet2.Cells.Clear 'Sheet2为临时工作表
- Sheet1.Range(Split(RangeName, ":")(0)).Resize(UBound(arr), UBound(arr, 2)) = arr '测试效果
- Debug.Print Timer - t
- End Sub
- Sub bbb(Path, WorkbookName, SheetName, RangeName)
- With Sheet2
- With .Range(RangeName)
- f = "'" & Path & "\[" & WorkbookName & "]" & SheetName & "'!" & Split(RangeName, ":")(0)
- .Formula = "=IF(ISBLANK(" & f & ")," & """""" & "," & f & ")"
- .Value = .Value
- '''0值 替换为 空
- ''' .Replace 0, "", xlWhole
- End With
- End With
- End Sub
复制代码
|
|