将功能保存到我的用户窗体后,出现运行时错误1004

时间:2018-08-18 10:22:47

标签: excel vba

下面的代码用于在组合表中容纳Sheets(“ Database”)。range(“ B:B”)中的地址列表,并将其“加载”到特定的表中,以用于打印报价。当我将保存添加到同一行VBA时,它开始给我运行时错误'1004':对象_worksheet的方法'Range'失败。当我在下面的代码中注释掉时,UserForm将加载空白的组合框。

Private Sub UserForm_Initialize()
Dim range As range
Dim ws As Worksheet
Set ws = Worksheets("Database")
For Each range In ws.range("Full Property Address")
Me.ComboBox1.AddItem range.Value
Next range
End Sub

通过上述方式,当我添加“保存”功能时停止工作:

Private Sub CommandButton1_Click()
Dim Address As Variant
Application.ScreenUpdating = False
Worksheets("Form").Activate

Worksheets("Form").range("A3").Select

Address = Worksheets("Form").range("A3").Value

'--------------------------------
Selection.Copy
Sheets("Database").Select
range("B1").Select
Cells.Find(What:=Address, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
'--------------------------------followed by a whole bunch of those

Unload Me
Sheets("Form").Activate

Application.ScreenUpdating = False
End Sub

0 个答案:

没有答案