VBA用户窗体-运行时错误1004“应用程序定义或对象定义的错误”

时间:2018-08-03 11:44:51

标签: excel vba excel-vba runtime-error userform

我明白了

  

运行时错误1004'应用程序定义的错误或对象定义的错误'

当我要运行用户窗体时,在第一个单元格值行( .Cells(last, 1).Value = Val(TextBox1) )

用户表单是通过另一个工作表上的按钮触发的,并且用户表单中键入的数据应传递到工作表“ MBE_Statistik”上的第一行。因为我在此工作表上的数据被格式化为表格,所以我首先要激活自动填充功能并针对表格进行扩展(因为存档将在可能具有不同设置的其他计算机上打开)。

Private Sub CommandButton1_Click()

Dim last As Long

With Application.AutoCorrect
.AutoExpandListRange = True
.AutoFillFormulasInLists = True

End With

last = ThisWorkbook.Worksheets("MBE_Statistik").Cells(Rows.Count, 1).End(xlUp).Row + 1

With ThisWorkbook.Worksheets("MBE_Statistik")

'KW
.Cells(last, 1).Value = Val(TextBox1)

'Center Code
.Cells(last, 3).Value = Val(TextBox2)

'Ort
.Cells(last, 4).Value = Val(TextBox3)

'Projekt
If OptionButton1.Value = True Then .Cells(last, 5).Value = "Neustarter"
If OptionButton2.Value = True Then .Cells(last, 5).Value = "ISB"
If OptionButton3.Value = True Then .Cells(last, 5).Value = "Leadgenerierung"
If OptionButton4.Value = True Then .Cells(last, 5).Value = "Center Flights"

'Flight-Nr
.Cells(last, 6).Value = Val(TextBox5)

'Ansprechpartner
.Cells(last, 7).Value = Val(TextBox4)

'Agent
.Cells(last, 10).Value = Val(TextBox6)

'Ist-Stunden
.Cells(last, 8).Value = Val(TextBox13)

'Ist-Stunden
.Cells(last, 9).Value = Val(TextBox7)

'Wählversuche
.Cells(last, 11).Value = Val(TextBox8)

'Erreicht AP/Entscheider
.Cells(last, 12).Value = Val(TextBox9)

'Kein Interesse
.Cells(last, 13).Value = Val(TextBox16)

.
.
.

End With

End Sub

由于错误在第一个突出显示,此刻我遗漏了一些文本框。

有人可以帮我找到问题吗?

0 个答案:

没有答案