|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim strFileName$, strPath$, wks As Worksheet, dic As Object, vKey
Application.ScreenUpdating = False
strPath = ThisWorkbook.Path & "\"
strFileName = strPath & "导出数据.xls"
If Dir(strFileName) = "" Then MsgBox "数据文件不存": Exit Sub
Set dic = CreateObject("Scripting.Dictionary")
With GetObject(strFileName)
For Each wks In .Worksheets
If isSheetExists(wks.Name) Then
Worksheets(wks.Name).Cells.Clear
wks.UsedRange.Copy Worksheets(wks.Name).[A1]
End If
Next
.Close False
End With
Application.ScreenUpdating = True
End Sub
Function isSheetExists(wksName$) As Boolean
On Error Resume Next
Set tempsheet = Worksheets(wksName)
If Err.Number = 0 Then
isSheetExists = True
Else
isSheetExists = False
End If
End Function
|
评分
-
3
查看全部评分
-
|