[Solved] Clear Excel Cell if Value less than another Cell value

[ad_1]

I believe this is what you are looking for below, this will take a value from cell B1 and compare against values in Column A, and if the values are less than the value in B1, it will clear the contents of that cell:

Sub ClearLowerThan()
    Dim c As Range, Rng As Range
    Dim LastRow As Long        
    Dim ws As Worksheet: Set ws = Sheets("Sheet1")
    'declare you worksheet, amend as required
    LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    'get the last row with data on Column A

    CompareVal = ws.Range("B1").Value
    'get the value to compare against, in this case from cell B1

    Set Rng = ws.Range("A1:A" & LastRow)
    'set the range to compare against the value from B1

    For Each c In Rng 'for each cell in the given range
        If c.Value < CompareVal Then c.ClearContents
        'if value of cell is less than the value to compare against, clear the cell contents.
    Next
End Sub

[ad_2]

solved Clear Excel Cell if Value less than another Cell value