VBA modify Code to say if range value = 2-100

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
In the below code it deletes any of the cells A-D in which the the value of Column E = 1.
I would like to modify this so if the value is 2-100.

Any help is appreciated,

VBA Code:
Public Sub EmptyOutABCAllSheets()


Dim lLastRow As Long
Dim vList() As Variant


vList = Array("Data1", "Data2", "Data3", "Data4")

On Error Resume Next 'It will error out on non-existent sheet or empty data

Application.ScreenUpdating = False
For j = LBound(vList) To UBound(vList)
    With Sheets(vList(j))
    lLastRow = .Cells.Find(What:="*", LookIn:=xlValues, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        For i = 1 To lLastRow
            If .Range("E" & i).Value = "1" Then
            .Range("A" & i).Resize(1, 4).ClearContents
            End If
        Next i
    End With
Next j
Application.ScreenUpdating = True
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
First, don't put numeric values in quotes. I am assuming that column E actually contains numeric values.

Replace your If statement with:
VBA Code:
            If .Range("E" & i).Value >= 2 And .Range("E" & i).Value <= 100 Then
 
Upvote 0
Solution

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top