运行时错误1004应用程序定义或对象定义的错误

你好我得到错误1004当我运行下面的代码。 基本上代码将我的表单与其他工作表中的表单进行比较并复制数据。 我知道这个错误很简单,我可以搞清楚,但我在截止date..请指教

Sub test() Dim lastCol, lastRow As Long, k, e As Long, a As Variant, b As Variant, cmpRng As Range Dim mastCol As Long, mastRng As Range, n As Long Dim Wbk As Workbook Dim file As String Dim SelectedFiles As Object Dim filename As Variant Dim indx As Long Dim t As Integer ChDrive "G:\" ' To set the drive where the files are located. ChDir "g:\work" 'To set the folder where the files are located. This is done to save time locating the folder through pop up box always. Application.ScreenUpdating = False Sheets("Temp Calc").Select 'Clear existing sheet data ecept header. Rows(1).Offset(1, 0).Resize(Rows.Count - 1).ClearContents filename = Application.GetOpenFilename(FileFilter:="microsoft excel files (*.xlsx), *.xlsx", Title:="Get File", MultiSelect:=True) Worksheets("Temp Calc").Select lastCol = Worksheets("Temp Calc").Cells(1, Columns.Count).End(xlToLeft).Column lastRow = Worksheets("Temp Calc").Cells(Rows.Count, 1).End(xlDown).Row Set cmpRng = Range(Cells(1, 1), Cells(1, lastCol)) a = cmpRng mastCol = Cells(1, Columns.Count).End(xlToLeft).Column Set mastRng = Range(Cells(1, 1), Cells(1, mastCol)) b = mastRng For t = 1 To UBound(filename) Workbooks.Open (filename(t)) For k = 1 To lastCol For n = 1 To mastCol If UCase(a(1, k)) = UCase(b(1, n)) Then Worksheets("Sheet1").Range(Cells(2, n), Cells(lastRow, n)).Copy Windows("Dashboard_for_Roshan.xlsm").Activate Worksheets("Temp Calc").Select Cells(2,k).PasteSpecial Paste:=xlPasteAll,Operation:=xlNone,SkipBlanks:=False,Transpose:=False ****< I get an error for the above line >**** Exit For End If Next Next Next t Application.ScreenUpdating = True End Sub 

更换

 Worksheets("Temp Calc").Select Cells(2,k).PasteSpecial Paste:=xlPasteAll,Operation:=xlNone,SkipBlanks:=False,Transpose:=False 

 Application.Goto Worksheets("Temp Calc").Cells(2, k) ActiveSheet.Paste