Excel VBA: replace entire cell with value -
can me loop go through cells a3:a50 , replace entire cell new value.
reference below:
[ita-it] it
[jpn] ja
[por-br] ptbr
[spa-es] es
etc.
thanks tips!
try:
sub replacevalues() dim r range dim v() variant dim integer v = [{"ita-it","it";"jpn","ja";"por-br","ptbr";"spa-es","es"}] set r = activesheet.range("a3:a50") = lbound(v) ubound(v) r.replace what:=v(i, 1), replacement:=v(i, 2), lookat:=xlwhole, matchcase:=false next end sub edit: there's no problem having 50 (or more) replacement pairs, easier manage storing them in table in workbook, rather listing them in vba array:
you can replace cell contents have text before / after lookup value using wildcards. combining changes, code becomes:
sub replacevalues2() dim r range dim v() variant dim integer v = sheet1.listobjects("tbreplacement").databodyrange set r = activesheet.range("a3:a50") = lbound(v) ubound(v) r.replace what:="*" & v(i, 1) & "*", replacement:=v(i, 2), lookat:=xlwhole, matchcase:=false next end sub 
Comments
Post a Comment