I have a bit of code that checks a userform for data in a combobox. Then if found adds a row to the table. Unfortunately, I am finding that some times it does not add the row and just overwrites the line. Any ideas on what I have done wrong would help. The following is the code for the portion that creates the new line:
If Not vbNullString = Me.CrimeSN2.Value Then
If Not vbNullString = Me.RowNumber.Value Then
rownumval = Me.RowNumber.Value
Worksheets("Offense").ListObjects("OffenseTable").ListRows.Add (rownumval)
rownumval = rownumval + 1
Else
rownumval = LastRow + 1
Worksheets("Offense").ListObjects("OffenseTable").ListRows.Add (rownumval)
rownumval = rownumval + 1
end if
Ifor theElsepart of your code, or both? Is LastRow correct when you step through your code using F8?Me.RowNumber.Value) is not Null, however, it may not be a number. If it's not a number, the .Add will fail.Ifportion. and LastRow is correct. I have stepped through it and it reads rownumval as a long and has value. it just seems to not work on the.ListRows.Add (rownumval). To Old UglyMe.RowNumber.Valueis reading as long and has value. I did try the code you provided but still continues with the error.