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

我在Excel 2010中有这个子应该做到以下几点:

·将Sheet1(Form)中的(6,4)中的值取出并在Sheet7的(date)列1中find该值

·find它find这个匹配的行

·在Sheet7(row,6)中查找值

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

Sheet1标题为Form,Sheet7标题为date。

这是我写的代码。 当我尝试运行它,它给了我在表(“date”)运行时错误'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 

您没有正确使用范围对象 ,

例如

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

更换

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

 Sheets("Form").Cells(19, 5)= Sheets("Dates").Cells(ProjRow, 6)