Find multiple values then delete cell and the next cell to the right

  • Hi,


    I'm struggling with an issue I have deleting cells with specific criteria. The criteria is "Payslips", "Salary", "No pay / reduced pay" which may or may not be listed in column "S". Column "S" contains unique values.
    If a cell within column "S" contains one of the above criteria, I need it to then delete that cell and offset(0'1)


    I've tried various options but majority of what's out there deletes the entire row.


    Thanks,
    Daren

  • Re: Find multiple values then delete cell and the next cell to the right


    Try



    HTH

    Regards

    Attila

  • Re: Find multiple values then delete cell and the next cell to the right


    Hi,I tried your code and the next issue is that it deletes any cells that contain the criteria. How do I change the code so that it only selects the cells that match the criteria?

  • Re: Find multiple values then delete cell and the next cell to the right


    try

    Code
    Sub test()
    Dim i As Long
    For i = Range("s" & Rows.Count).End(xlUp).Row To 1 Step -1
        Select Case Cells(i, "s").Value
            Case "Payslips", "No pay / reduced pay", "Salary"
                Cells(i, "s").Resize(, 2).Delete xlShiftToLeft
        End Select
    Next
    End Sub
  • Re: Find multiple values then delete cell and the next cell to the right


    Replace "1" with "6"
    i.e.

    Code
    For i = Range("s" & Rows.Count).End(xlUp).Row To 6 Step -1


    If you want to Select then

  • Re: Find multiple values then delete cell and the next cell to the right


    Thanks,I tried the code and I get an 'End Select' error as if it can't see the Select Case.

  • Re: Find multiple values then delete cell and the next cell to the right


    OOps,


    Missed an End If


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!