PDA

View Full Version : [SOLVED:] Deleting a row



oam
10-30-2017, 08:37 PM
I need a good way to delete a row after I do a search and find a tracking number in a column.
I have made a “Summary” worksheet where I can search for tracking numbers from the main data sheet containing over 20000 records. I enter the tracking number into a search formula on the Summary sheet and it finds the line number of the tracking number on the MainData sheet and it returns the row number. I need a way to take that row number or some other way to delete the entire row on the MainData sheet that tracking number is on.

Does anyone know of a way I can do this?
Thank you for any and all help.

offthelip
10-31-2017, 11:40 AM
Try this sub, if you select the cell which has got the row number in that you want to delete. then run the macro.


Sub Deleterow()
rowno = ActiveCell.Value
If rowno <> "" Then
If (IsNumeric(rowno)) Then


Worksheets("MainData").Rows(rowno).EntireRow.Delete Shift:=xlUp
End If
End If
End Sub

oam
10-31-2017, 02:45 PM
offthelp,

Works great but I had to DIM "rowno" for it to work but other than that, works great.
Thank you for your quick response.

offthelip
10-31-2017, 03:34 PM
You only need to DIM "Rowno" if you use "option explicit"
It should work perfectly Ok without it.
I personally never use option explicit since I prefer to use self explicit names, (e.g. ROWNO) and I find the typing of variables in VBA tends to be unhelpful since most of them end up being Variants because they are associated with cells.