I'm at wits end...
I have two ActiveX control buttons on a Worksheet ("Servers_Test"): btnAddWindowsLinux and btnDeleteWindowsLinux.
Here are the following VBA macros, respectively:
This is a completely random error message that appears. Even if I add multiple rows, then delete them (using the control buttons), then go to add more, I get the Run-time error '-2147417848 (80010108)': "Method 'Add' of object 'ListRows' failed" window. Following a "Debug" selection (and having VBA identify the line of code that is causing the error), when I stop the macro and press the "Add New Server" button (btnAddWindowsLinux), I get a new error message: "Run-time error '1004': Application-defined or object-defined error".
I've been to NUMEROUS Excel help sites with absolutely no luck. Can anyone please help me eliminate these random, inconvenient, and unproductive errors from occuring?
Thank you, in advance, for any assistance you can provide.
- Matt
I have two ActiveX control buttons on a Worksheet ("Servers_Test"): btnAddWindowsLinux and btnDeleteWindowsLinux.
Here are the following VBA macros, respectively:
Rich (BB code):
Option Explicit
Private Sub btnAddWindowsLinux_Click()
Dim servers As Worksheet
Dim serverTable As ListObject
Dim serverTableRow As ListRow
Dim serverTableRows As ListRows
Set servers = ThisWorkbook.Worksheets("Servers_Test")
Set serverTable = servers.ListObjects("WindowsLinux")
Set serverTableRow = serverTable.ListRows.Add(AlwaysInsert:=True) ' Reference line where error(s) are occuring for adding a row to the table
If serverTable.ListRows.Count > 1 Then
btnDeleteWindowsLinux.Enabled = True
End If
End Sub
Private Sub btnDeleteWindowsLinux_Click()
Dim servers As Worksheet
Dim serverTable As ListObject
Dim serverTableRow As ListRow
Dim serverTableRows As ListRows
Set servers = ActiveWorkbook.Worksheets("Servers_Test")
Set serverTable = servers.ListObjects("WindowsLinux")
Set serverTableRows = serverTable.ListRows
If serverTableRows.Count > 1 Then
serverTable.ListRows(serverTable.ListRows.Count).Delete ' Reference line where error(s) are occuring for adding a row to the table
If serverTable.ListRows.Count > 1 Then
btnDeleteWindowsLinux.Enabled = True
Else
btnDeleteWindowsLinux.Enabled = False
End If
End If
I've been to NUMEROUS Excel help sites with absolutely no luck. Can anyone please help me eliminate these random, inconvenient, and unproductive errors from occuring?
Thank you, in advance, for any assistance you can provide.
- Matt
Last edited by a moderator: