Excel Macro to replace numeric zip code with county name -


issue - have spreadsheet thousands of addresses no counties.

goal - add counties each record. can identify counties using zip codes , have list of zip codes , county names.

what i've tried far - county names in column , it's corresponding zip code in column b. copied address list same spreadsheet starting zip codes in column d.

enter image description here

i wrote following simple macro compare , replace zip codes county names. runs doesn't seem replace anything. don't errors, i'm not sure problem is. ideas?

  public sub take_two_replace_zip_with_name()    dim lastbcell long   dim b integer   dim bcell range    lastbcell = activesheet.range("b65000").end(xlup).row    b = lastbcell 2 step -1   set bcell = activesheet.cells(b, 2)    if bcell = bcell.offset(0, 2) bcell.offset(0, 2) = bcell.offset(0, -1)   next b    end sub     

ok, worked out myself:

  each bcell in range("b2:b100").cells    columns("d:d").cells.replace what:=bcell, replacement:=bcell.offset(0, -1).value,          lookat:=xlpart, _           searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _           replaceformat:=false    next bcell 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -