Excel运行时错误1004 [英] Excel Runtime Error 1004

查看:143
本文介绍了Excel运行时错误1004的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual Basic的新手.我创建了一个工作正常的电子表格,直到将条目从其中复制到另一张纸上为止!

I am new to Visual Basic. I created a spreadsheet which worked fine until I copied entries from it to another sheet!

显然,每当我单击查找条目"表单上的继续"按钮时,我都会收到运行时错误1004,并且下拉菜单中也没有显示任何内容,但我从未更改过代码.当我单击调试"时,

Apparently, whenever I click the CONTINUE button on the Find Entry form I get the runtime error 1004 also the drop down shows nothing in it yet I never changed the code. When I click Debug,

TargetRow = Application.WorksheetFunction.Match(ColumnD_Menu, Sheets("Data").Range("Dyn_Full_Name"), 0) 

被突出显示,我不知道如何进行操作,因为我从没碰过这行代码.

is highlighted and I don’t know how to proceed with it as I never touched this line of code at all.

可能是什么问题,我该如何解决?

What could be the problem and how can I resolve it?

下面是我的代码

Option Explicit

Private Sub CommandButton1_Click()

    Dim TargetRow As Integer

    TargetRow = Application.WorksheetFunction.Match(ColumnD_Menu, Sheets("Data").Range("Dyn_Full_Name"), 0)
    Sheets("Engine").Range("B5").Value = TargetRow

    Unload Find_Entry_UF

    Data_UF.Txt_FirstName = Sheets("Data").Range("Data_Start").Offset(TargetRow, 1).Value
    Data_UF.Txt_Surname = Sheets("Data").Range("Data_Start").Offset(TargetRow, 2).Value


    Data_UF.Combo_Age = Sheets("Data").Range("Data_Start").Offset(TargetRow, 4).Value
    Data_UF.Combo_Marital = Sheets("Data").Range("Data_Start").Offset(TargetRow, 5).Value
    Data_UF.Combo_Gender = Sheets("Data").Range("Data_Start").Offset(TargetRow, 6).Value


    If Sheets("Data").Range("Data_Start").Offset(TargetRow, 7).Value = "Yes" Then
        Data_UF.Option_Y_Children = True
    Else
        Data_UF.Option_N_Children = True
    End If

    Data_UF.Combo_Religion = Sheets("Data").Range("Data_Start").Offset(TargetRow, 8).Value
    Data_UF.Txt_Address = Sheets("Data").Range("Data_Start").Offset(TargetRow, 9).Value
    Data_UF.Combo_FileNumber = Sheets("Data").Range("Data_Start").Offset(TargetRow, 10).Value

推荐答案

1004错误源于以下事实:在Excel文件中,以下2个条件中至少有1个缺失:

The 1004 error comes from the fact, that in the Excel file at least 1 of the following 2 conditions are missing:

  • 没有名为Data
  • 的工作表
  • 工作表Data
  • 上没有命名范围Dyn_Full_Name
  • There is no sheet named Data
  • There is no named range Dyn_Full_Name on the sheet Data

相应地调整工作表,错误将得到解决.

Adjust the worksheet correspondingly and error would be fixed.

这篇关于Excel运行时错误1004的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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