samedi 18 août 2018

Excel if value in range is larger than value in a cell, clear value of cell in range

I want to type a number in B3. If a number in the range B8 to B200 is larger than the value in B3, the cell in the range whose value is larger than that of B3's value will be cleared of its contents. (I tried doing this with the code attached)

(OR: If a value is entered in B3, a drop down of all the values that are less than or equal to the value in B3 is generated (that way there is no way to exceed the value in B3).)

Sub ProcessLineNumberValidation()




Dim QTY As Integer
Dim ProcessNum As Integer
Dim ws As Worksheet

Set ws = ThisWorkbook.Sheets("Ozone Generator")


QTY = ws.Sheets("Ozone Generator").Cells(3, 2).Value

For i = 8 To 200

ProcessNum = ws.Sheets("Ozone Generator").Cells(i, 2).Value


    If ProcessNum > QTY Then

    ws.Sheets("Ozone Generator").Cells(i, 2).ClearContents

    End If

Next i



End Sub

Aucun commentaire:

Enregistrer un commentaire