excel vba - AutoFilter Method of Range Class Failed VBA -
i having issue autofilter in vba. have data on 1 sheet deleted based on values entered in sheet. in other words, user inputs 2 values (greater "500" , less "-500") , autofilter deletes data on first sheet based on user inputs.
sub autofilter() dim wksdest worksheet dim lastrow1 long dim lastrow2 long dim rng range dim rngdelete range application.screenupdating = false application.calculation = xlcalculationmanual set wksdest = worksheets("sheet2") worksheets("sheet2").select wksdest lastrow2 = .cells(.rows.count, "d").end(xlup).row set rng = range(cells(2, "d"), cells(lastrow2, "d")) rng.autofilter field:=2, criteria1:=">=" & worksheets("holders (corp)").range("e2").value, _ operator:=xland, criteria2:="<=" & worksheets("holders (corp)").range("f2").value set rngdelete = rng.specialcells(xlcelltypevisible) rng.autofilter rngdelete.entirerow.delete end application.screenupdating = true application.calculation = xlcalculationautomatic end sub
any finding out why autofilter based on 2 criteria not working appreciated!
Comments
Post a Comment