如何将表格1中Excel表单的记录保存/添加到Excel表格2中

如何将表格1中Excel表单的记录保存/添加到Excel表格2中,excel,vba,Excel,Vba,第行调试错误-设置myRng=.Range(myCopy) 无法理解问题是什么,我的数据包含筛选的数据验证列表 在没有验证列表的情况下,所需单元格中的数据可以完美复制 Sub AddGAP() Dim gapscore As Worksheet Dim gapdata As Worksheet Dim nextRow As Long Dim oCol As Long Dim myRng As Range Dim myCopy As String Dim myCell As Range '

第行调试错误-设置myRng=.Range(myCopy)

无法理解问题是什么,我的数据包含筛选的数据验证列表

在没有验证列表的情况下,所需单元格中的数据可以完美复制

Sub AddGAP()

Dim gapscore As Worksheet
Dim gapdata As Worksheet

Dim nextRow As Long
Dim oCol As Long

Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Gapscore Sheet - some contain formulas
myCopy = "A2 ,B2 ,C2 ,D2, ,A6 ,M6 ,N6 ,Q6 ,R6 ,S6 ,T6 ,X6 ,Y6 ,Z6 ,AA6 ,J6 ,L6"

Set gapscore = Worksheets("Gap Analysis Score")
Set gapdata = Worksheets("GAPData")

With gapdata
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With

With gapscore
Set myRng = .Range(myCopy)
End With

With gapdata
For Each myCell In myRng.Cells
    oCol = oCol + 1
    gapdata.Cells(nextRow, oCol).Value = myCell.Value
    Next myCell 
 End With
 End Sub
在线调试错误-设置myRng=.Range(myCopy)


错误对话框-运行时错误:1004-对象“工作表”的方法“范围”失败


应该将什么更改为什么值才能使代码准确运行?

您收到的错误是什么?运行时错误:1004-对象“工作表”的方法“范围”失败