运行时错误424对象必需(在数据条目用户表单中添加数据)

时间:2017-11-23 07:31:08

标签: excel vba excel-vba

我是VBA的新手,根本没有任何背景。我刚看了youtube视频并尝试学习。我正在为货件摘要信息输入数据。但是,当我运行Userform时,我遇到了Runtime Error 464。我一遍又一遍地查看我的代码,无法找出解决方案。在此先感谢那些有帮助的人!

Private Sub CommandButton1_Click()
    Dim TextBox As String
    Dim Database As Worksheet
    Set Database = Worksheets("ShipData")

    eRow = ThisWorksheet.ShipData.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

    ShipData.Cells(eRow, 1).Value = TextBox6.Text
    ShipData.Cells(eRow, 1).Value = ComboBox1.List
    ShipData.Cells(eRow, 2).Value = ComboBox2.List
    ShipData.Cells(eRow, 3).Value = TextBox1.Text
    ShipData.Cells(eRow, 4).Value = TextBox2.Text
    ShipData.Cells(eRow, 5).Value = TextBox3.Text
    ShipData.Cells(eRow, 6).Value = ComboBox3.List
    ShipData.Cells(eRow, 7).Value = TextBox4.Text
    ShipData.Cells(eRow, 8).Value = TextBox5.Text
    ShipData.Cells(eRow, 9).Value = ComboBox4.Text
    ShipData.Cells(eRow, 11).Value = TextBox7.Text
    ShipData.Cells(eRow, 12).Value = TextBox8.Text
    ShipData.Cells(eRow, 13).Value = TextBox9.Text
    ShipData.Cells(eRow, 14).Value = TextBox10.Text
    ShipData.Cells(eRow, 15).Value = TextBox11.Text
    ShipData.Cells(eRow, 16).Value = TextBox12.Text
    ShipData.Cells(eRow, 17).Value = TextBox13.Text
    ShipData.Cells(eRow, 18).Value = TextBox14.Text
    ShipData.Cells(eRow, 19).Value = TextBox15.Text
    ShipData.Cells(eRow, 20).Value = TextBox16.Text

    Unload Me
    ShipmentSummary.Show
End Sub

1 个答案:

答案 0 :(得分:0)

Set "ShipData"工作表已Set Database = Worksheets("ShipData") Database,因此您现在可以使用ThisWorksheet.ShipData而不是Private Sub CommandButton1_Click() Dim TextBox As String Dim Database As Worksheet Set Database = Worksheets("ShipData") With Database eRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Row .Cells(eRow, 1).Value = TextBox6.Text .Cells(eRow, 1).Value = ComboBox1.List '<-- better use ComboBox1.Value .Cells(eRow, 2).Value = ComboBox2.List '<-- better use ComboBox2.Value .Cells(eRow, 3).Value = TextBox1.Text .Cells(eRow, 4).Value = TextBox2.Text .Cells(eRow, 5).Value = TextBox3.Text .Cells(eRow, 6).Value = ComboBox3.List '<-- better use ComboBox3.Value .Cells(eRow, 7).Value = TextBox4.Text .Cells(eRow, 8).Value = TextBox5.Text .Cells(eRow, 9).Value = ComboBox4.Text '<-- better use ComboBox4.Value .Cells(eRow, 11).Value = TextBox7.Text .Cells(eRow, 12).Value = TextBox8.Text .Cells(eRow, 13).Value = TextBox9.Text .Cells(eRow, 14).Value = TextBox10.Text .Cells(eRow, 15).Value = TextBox11.Text .Cells(eRow, 16).Value = TextBox12.Text .Cells(eRow, 17).Value = TextBox13.Text .Cells(eRow, 18).Value = TextBox14.Text .Cells(eRow, 19).Value = TextBox15.Text .Cells(eRow, 20).Value = TextBox16.Text End With Unload Me ShipmentSummary.Show End Sub 来引用它。

我相信这是你想要实现的目标:

-(CGFloat)tableView:(UITableView *)tableView 
         estimatedHeightForHeaderInSection:(NSInteger)section
{
      return 44.0f;
}