What is causing run-time error 9?

Jordan Lindsey 1 Reputation point
2021-08-31T01:05:32.06+00:00

I am creating an inventory tracking spreadsheet with UserForm Entry. The button I've created to transfer the data to a table is giving me "Run-tim error 9 (Subscript out of range)". The code is as follows:

Sub CommandButton1_Click()

'Enter button

Dim rng As Range
Set rng = Worksheets("Updates").ListObjects("Table1").Range
Dim LastRow As Long
LastRow = rng.Find("", rng.Cells(1), x1Formulas, x1Part, x1ByRows, xlPrevious, False).Row

rng.Parent.Cells(LastRow + 1, 1).Value = TextBox1.Value
rng.Parent.Cells(LastRow + 1, 2).Value = TextBox2.Value


MsgBox ("Inventory Updated")

End Sub

The row in bold is the line that is highlighted when attempting to debug. What is causing this issue?

0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.