Consulting

Results 1 to 4 of 4

Thread: Solved: Help with Find/Delete Entire Row

  1. #1

    Solved: Help with Find/Delete Entire Row

    Hello,

    I have a VBA code that brings up an inputbox, searches for this RP# (which has to be in text form) and deletes the entire row that has the RP# in it

    [vba]Sub Override()
    Dim RPtoDel As String
    Dim delrows As Long
    RPtoDel = InputBox("Enter RP#")
    Do While True
    On Error GoTo Err_Handle
    Worksheets("PY Query").Select
    Range("P:P").Find(What:=RPtoDel, LookIn:=xlValues, LookAt:=xlWhole, After:=ActiveCell).EntireRow.Delete Shift:=xlUp
    delrows = delrows + 1
    Loop
    Err_Handle:
    MsgBox "Number of Deleted Rows - " & delrows
    Worksheets("Ex Resident").Select
    Range("B3").Select
    End Sub[/vba]

    Unfortunately it is not finding the RP# in the list. I have double checked to make sure the RP#'s are in the list and they are. I am wondering if it has to do with the number having to be in text form (which it has to be since the query upload to the excel sheet has the RP# in text). Thanks for your help

  2. #2
    Would this do it? (On a copy of your workbook)

    [VBA]Sub Try_This()
    Dim RPtoDel As String
    Dim delrows As Long
    With Application
    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    RPtoDel = InputBox("Enter RP#")
    With Worksheets("PY Query")
    .Columns(16).Replace (RPtoDel), "", xlPart
    .Columns(16).SpecialCells(4).EntireRow.Delete
    End With
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    End With
    End Sub[/VBA]

  3. #3
    Unfortunately it did not work. It showed a Run-Time error '1004': No cells were found.

  4. #4
    Please disregard the last reply, it actually did work!! Thanks so much for your help jolivanes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •