VBA to delete cell value from a range of cells if cell value = another cell value.

  • Re: VBA to delete cell value from a range of cells if cell value = another cell value


    Maybe this.
    Sheet2 is the cover sheet, sheet1 is the sheet with data.

    Code
    Sub Newbie40()
    Dim ws As Worksheet, numRemove As Long, r As Range
    Set ws = Worksheets("Sheet2")
        numRemove = ws.Range("D1").Value
        With Worksheets("Sheet1")
            For Each r In .Range("A3", .Range("A" & Rows.Count).End(xlUp))
                If r.Value = numRemove Then r.Value = ""
            Next r
        End With
    End Sub

    Bruce :cool:

  • Re: VBA to delete cell value from a range of cells if cell value = another cell value


    Sorry I should have stated that all data is on the same sheet. i have written code to delete a sheet which has been chosen from a range of cells on the cover sheet, which is A3 - the last row. the value aslo goes into cell d1 on the cover sheet. what i am trying to do is delete the value within the range a3 - a lastrow if it is the same as cell d1. i have tried to modify what you have written with no luck.

Participate now!

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