I was wondering why my code doesn't work when I use a variable to delete a given row from a table when it works fine if I put a number in the brackets. The code doesn't do anything extraordinary. It goes through a cycle and finds the row I want to delete and then returns its number.
And there is the line I have the problem with:
Inventory.ListRows(Talalat).Delete 'where Inventory is a Listobject and Talalat is Long
I definitely get the correct number from the code for the row I want to delete, and it runs fine without error messages but it just doesn't do what it has to. But when I insert the number manually into the code it works just fine... Any thoughts?
PS: the entire code is below if you'd want to look into it.
Private Sub CommandButton17_Click()
Dim CounterA As Long
Dim Talalat As Long
Dim ANsWR As Integer
Set invent = Sheets("CORE").ListObjects("Inventory")
If Not ComboBox4.Value = "" And Not ComboBox4.Value = "<Új tárgy>" Then
Talalat = 0
For CounterA = 1 To invent.Range.Rows.Count
If ComboBox4.Value = invent.Range.Cells(CounterA, 1) Then Talalat = CounterA
Next
If Talalat > 0 Then
ANsWR = MsgBox("Biztosan törli a(z) " & invent.Range.Cells(Talalat, 1) & Chr(13) & "nevű tárgyat az adatbázisból?", vbYesNo, "Tuti?")
If ANsWR = vbNo Then
Exit Sub
Else
Sheets("CORE").Unprotect
invent.ListRows(Talalat).Delete 'Where the glitch is
End If
End If
End If
End Sub



