应用程序定义或对象定义的错误Excel [英] Application-Defined or Object-Defined Error Excel

查看:949
本文介绍了应用程序定义或对象定义的错误Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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



·查找找到此匹配的行



·查找Sheet7(row,6)的值



将其粘贴到Sheet1(19,5)



Sheet1标题为Form,Sheet7标题为日期。



这是我写的代码。当我尝试运行它,它给我运行时错误'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)。列(1).Find(what:= ProjNo,LookIn:= xlValues,lookat:= xlWhole)

如果找到没有则
MsgBox 找不到项目。
EnterProj.Show
Else
ProjRow = Found.Row
End If

表格(Dates)。Range(ProjRow,6).Copy目的地:= Sheets(Form)。Range(19,5)

End Sub


解决方案

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





.Range(2,6) 细胞(2,6) ,范围参数必须为 A1样式参考其他样式



替换

 表格(日期)范围(ProjRow,6).Copy目的地:=表格(表单)范围(19,5)

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


I have this sub in Excel 2010 that’s supposed to do the following:

·         Take the value in (6, 4) in Sheet1(Form) and find this value in Sheet7’s (Dates) column 1

·         Find the row in which it finds this match

·         Find the value at Sheet7(row, 6)

·         Paste it into Sheet1(19, 5)

Sheet1 is titled Form, and Sheet7 is titled Dates.

This is the code that I’ve written. When I try to run it, it gives me a run-time error ‘1004: Application-defined or object-defined error’ at Sheets("Dates")... Any assistance would be greatly appreciated.    

 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

解决方案

You are not using the Range Object Correctly,

For e.g.

.Range(2,6)<>Cells(2,6), Range parameters has to be A1-style reference or other styles

Replace

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

with

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

这篇关于应用程序定义或对象定义的错误Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆