复制工作表时对象类型错误

时间:2018-12-04 04:51:23

标签: excel vba

我正在尝试打开一个存储在桌面上固定位置的文件,并将某个工作表复制到当前工作簿中。

我收到错误438。

Sub RangeCheckFormula()

Dim TargetFile As Workbook
Dim TargetSheet As Worksheet

Set TargetFile = ActiveWorkbook

ActiveSheet.Range("F1") = "#"
ActiveSheet.Range("G1") = "CLUSTER"
ActiveSheet.Range("H1") = "PROFILE"

Sheets.Add
ActiveSheet.Name = "Outlet List"

Set TargetSheet = ActiveSheet

Application.Workbooks.Open (Environ("USERPROFILE") & "\Desktop\REQUIRED 
FILES\" & "UPDATED_OUTLET_LIST")
CurrentSheet.Copy Before:=TargetFile.TargetSheet.Range("A1")

Workbooks("UPDATED_OUTLET_LIST.xlsx").Close SaveChanges:=False

End Sub

1 个答案:

答案 0 :(得分:0)

您需要的只是

FineMaster