excel vba - VBA code to find and replace using maybe wildcard? -
how can find , remove x strings, in other words, replace nx1 n1, nx2 n2, nx7535 n7535, strings start n not have x after n, if need remove x, below put crazy code adapted excel recording has easier way it:
sub find_nx_replace() range("a1").select range(selection, selection.end(xldown)).select selection.replace what:="nx1", replacement:="n1", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx2", replacement:="n2", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx3", replacement:="n3", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx4", replacement:="n4", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx5", replacement:="n5", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx6", replacement:="n6", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx7", replacement:="n7", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx8", replacement:="n8", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false selection.replace what:="nx9", replacement:="n9", lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false end sub example:
do loop of number:
sub find_nx_replace() dim long = 1 9 selection.replace what:="nx" & i, replacement:="n" & i, lookat:=xlpart, _ searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _ replaceformat:=false next end sub 
Comments
Post a Comment