When I execute the ADD button I get an error message:
run-time error '-2147417848 (80010108)':method 'add' of object 'listrows' failed
However, if I remove the "ListBox2" it works fine.
Any help would be appreciated.
****************************************************************
Code
Private Sub AddExpenses_Click()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If StaffName = "" Then
MsgBox "Vendor NAME cannot be empty.."
StaffName.SetFocus
Exit Sub
ElseIf ClientName = "" Then
MsgBox "GL ACCOUNT cannot be empty.."
ClientName.SetFocus
Exit Sub
ElseIf FoodDrink = "" Then
MsgBox "Total Invoice Amount cannot be empty.."
FoodDrink.SetFocus
Exit Sub
End If
'If CheckForErrors > 0 Then Exit Sub
Set ws = Sheets("Expense Report")
ws.Activate
ActiveSheet.ListObjects("Expenses").ListRows.Add
ModifyTableRow ExpensesTable.ListRows(ExpensesTable.ListRows.Count).Range
ChangeRecord_SpinDown
UpdatePositionCaption
Call calcul
ListBox2 = "expenses"
Worksheets("expense report").Activate
ThisWorkbook.Save
End Sub
Sub ModifyTableRow(TableRow As Range)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Worksheets("expense report").Select
Selection.Activate
Misc = ""
PriorHST = ""
TableRow.Select
Selection.Activate
With TableRow
MsgBox "The last ROW is: " & TableRow.Address
.Cells(1, 1) = Calendar1.Value
.Cells(1, 3) = StaffName.Value
.Cells(1, 5) = ClientName.Value
.Cells(1, 6) = Description.Value
'.Cells(1, 7) = ReceiptsYes.Value
'.Cells(1, 7) = ReceiptsNo.Value
.Cells(1, 8) = Airfare.Value
.Cells(1, 9) = Accommodation.Value
.Cells(1, 10) = GroundTransport.Value
.Cells(1, 11) = FoodDrink.Value
If ReceiptsYes.Value = True Then
.Cells(1, 7) = "Yes"
Else
.Cells(1, 7) = "No"
End If
Application.Calculation = xlCalculationAutomatic
Misc = .Cells(1, 12)
Misc = Format(Misc, "$#,##.00")
PriorHST = .Cells(1, 13)
PriorHST = Format(PriorHST, "$#,##.00")
End With
Application.Calculation = xlCalculationManual
End Sub
Display More