应用程序定义或对象定义错误Excel

Axx*_*ieD 2 excel vba excel-vba excel-2010

我在Excel 2010中有这个子应该执行以下操作:

·获取Sheet1(Form)中的(6,4)中的值,并在Sheet7(日期)列1中找到该值

·找到找到此匹配项的行

·在Sheet7中找到值(第6行)

·将其粘贴到Sheet1(19,5)

Sheet1标题为Form,Sheet7标题为Dates.

这是我写的代码.当我尝试运行它时,它在Sheets("日期")给我一个运行时错误'1004:应用程序定义的或对象定义的错误... ...将非常感谢任何帮助.    

 Option Explicit

Private Sub btnNext_Click()
        Dim ProjNo As String
        Dim ProjRow As Long
        Dim Found As Range   

    ProjNo = Worksheets("Form").Cells(6, 4).Value        

         Set Found = Sheets("Dates").Columns(1).Find(what:=ProjNo, LookIn:=xlValues, lookat:=xlWhole)

          If Found Is Nothing Then   
              MsgBox "Project not found."    
              EnterProj.Show    
         Else   
             ProjRow = Found.Row    
        End If        

          Sheets("Dates").Range(ProjRow, 6).Copy Destination:=Sheets("Form").Range(19, 5)    

End Sub
Run Code Online (Sandbox Code Playgroud)

eve*_*ime 5

您没有正确使用Range对象,

例如

.Range(2,6)<> Cells(2,6),范围参数必须是A1-style reference其他样式

更换

Sheets("Dates").Range(ProjRow, 6).Copy Destination:=Sheets("Form").Range(19, 5)
Run Code Online (Sandbox Code Playgroud)

Sheets("Form").Cells(19, 5)=  Sheets("Dates").Cells(ProjRow, 6) 
Run Code Online (Sandbox Code Playgroud)