vba conditional find & replace -
today stuck code while trying replace dot (.) if in list sheet1 not match 1 of values list of sheet (same workbook). "argument not optional" error not give me other hint.
sub filter(wss worksheet, wsn worksheet, integer, j integer, k integer, l integer, integer) ' ' substitute macro ' application.screenupdating = false range("a1").formular1c1 = "sorted" set wss = sheets("sheet1") set wsn = sheets("non_confid") col1 = "a" col2 = "e" col3 = "c"
for = 1 200 if wss.range(col1 & a) = wsn.range("ab2:ab600") = + 1 else: range(col1 & a).replace what:=".", replacement:="", lookat:=xlpart, searchorder:=xlbyrows, matchcase:=false, searchformat:=false, replaceformat:=false = + 1 end if next range("a1").autofilter activeworkbook.worksheets("sheet1").autofilter.sort.sortfields.clear activeworkbook.worksheets("sheet1").autofilter.sort.sortfields.add key:=range("a:a"), sorton:=xlsortonvalues, order:=xlascending, dataoption:=xlsortnormal activeworkbook.worksheets("sheet1").autofilter.sort .header = xlyes .matchcase = false .orientation = xltoptobottom .sortmethod = xlpinyin .apply end range("a1").select selection .horizontalalignment = xlcenter .verticalalignment = xlbottom .wraptext = false .orientation = 0 .addindent = false .indentlevel = 0 .shrinktofit = false .readingorder = xlcontext .mergecells = false end selection.interior .pattern = xlsolid .patterncolorindex = xlautomatic .color = 15773696 .tintandshade = 0 .patterntintandshade = 0 end selection.font .color = -10477568 .tintandshade = 0 end activesheet.listobjects.add(xlsrcrange, range("$a$1:$a$500"), , xlyes).name = "table1" activesheet.listobjects("table1").range.autofilter field:=1, criteria1:="<>" set wss = sheets("sheet1") 'this has assigned worksheet sheet1 wss set wsn = sheets("non_confid") 'this has assigned worksheet sheet1 wsu = 2 j = 2 300 if not isempty(wss.range(col1 & j).value) wss.range(col3 & - 1).value = wss.range(col1 & j).value = + 1 end if next range("a:b").entirecolumn.delete k = 1 300 if isempty(wss.range(col1 & k).value) = + 1 'exit 'this jumps out of loop, no more copying. else wsn.range(col2 & i).value = wss.range(col1 & k).value = + 1 end if next sheets("non_confid").select columns("a:g").entirecolumn.autofit range("e1").select activesheet.listobjects("status").range.autofilter field:=4, criteria1:="<>" range("a1").select activeworkbook.saved = true application.screenupdating = true
end sub
thank in advance time!
the required arguments replace
what , replacement, have supplied.
i not receive error message line:
if wss.range(col1 & a) = wsn.range("ab2:ab600")
because trying compare single value range
.
(i'm assuming wss , wsn set correctly worksheets.)
this cause of errrors. error message different suspicious not posting actual code, or enough of replicate problem.
Comments
Post a Comment