|
这也不是不可以- 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"
- For i = 2 To 21
- f = "'" & Path & "\[" & WorkbookName & "]" & SheetName & "'!" & i & ":" & i
- Sheet2.Cells(i - 1, 1) = "=MATCH(9.99999E+307," & f & ")"
- Next
- lie = WorksheetFunction.Max(Sheet2.Range("a1:a20").Value)
- lie1 = Split(Cells(1, lie - 8).Address, "$")(1)
- lie2 = Split(Cells(1, lie).Address, "$")(1)
- Sheet2.Cells.Clear 'Sheet2为临时工作表
- RangeName = lie1 & "2:" & lie2 & "21"
- bbb Path, WorkbookName, SheetName, RangeName
- Sheet1.Range(RangeName).Clear
- arr = Sheet2.Range(RangeName).Value
- '''Sheet2.Cells.Clear 'Sheet2为临时工作表
- Sheet1.Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr '测试效果
- '' 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
复制代码
|
-
|