I need to delete specific rows in a table with a order number. When I put this code in Excel it delete the entire table. What I want is to delete only specific rows. The tbxOrder is a text box. I want that when the text box equals x command number the code will select all the rows with the same number in the "Pagination" table (column 20) and then delete them. Thank you :)
Public Sub DeleteOrderRows()
Dim strNoOrder As String
Dim strNoFunction As String
Dim noCommande As Integer
Dim tblPagination As ListObject
Set tblPagination = Worksheets("Pagination").ListObjects.Item("tblPagination")
For Each srcrow In tblPagination.ListRows
strNoOrder = srcrow.Range.Cells(1, 20)
noOrder = tbxOrder.Value
If strNoOrder = noOrder Then
EntireRow.Delete
End If
Next
End Sub
Next srcrowand anEnd If... Also, when you dosrcrow.Range.Cells(1,20)(if that.Range.Cells()works), you're referring to the relativeCells(1,20)withinsrcRow. Is that what you mean? Are you not getting any error??srcrow.EntireRow.Delete.