当按下我的EXcel VBA表格的OK按钮时,信息不会正确地添加到数据表中

问题描述:

我想格式化一个“确定”按钮,以便表单中的所有信息填充我的下一个空行数据表。这是我到目前为止:当按下我的EXcel VBA表格的OK按钮时,信息不会正确地添加到数据表中

Private Sub OKButton_Click() 

Dim emptyRow As Long 

'Determine emptyRow 
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1 

'Transfer Information 
Cells(emptyRow, 1).Value = BoatModelComboBox.Value 
Cells(emptyRow, 2).Value = BoatIDTextBox.Value 
Cells(emptyRow, 3).Value = NameofDefectComboBox.Value 
Cells(emptyRow, 4).Value = InspectionAreaComboBox.Value 
Cells(emptyRow, 5).Value = DateTextBox.Value 
Cells(emptyRow, 6).Value = OccurenceTextBox.Value 
Cells(emptyRow, 7).Value = DefectOriginComboBox.Value 

If BoatCheckOptionButton1.Value = True Then 
    Cells(emptyRow, 8).Value = "TRUE" 
Else 
    Cells(emptyRow, 8).Value = "FALSE" 
End If 

If TireKickOptionButton1.Value = True Then 
    Cells(emptyRow, 9).Value = "TRUE" 
Else 
    Cells(emptyRow, 9).Value = "FALSE" 
End If 

Cells(emptyRow, 10).Value = TypeofInspectionComboBox.Value 
Cells(emptyRow, 11).Value = MonthComboBox.Value 

感谢您的帮助!

+0

为什么的这款不这样做你想要什么? –

+0

请告诉我们这里的问题......我假设braX得到了正确的答案,但这需要验证。 (-1&vtc) –

尝试获得的空行这样反而

emptyRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row + 1