excel - How to add a comma delimiter to the beginning of the city in an address -


example:

1412 chestnut street philadelphia 494 w germantown pike plymouth meeting 

i add comma beginning of each city in list of 200 can see above city name not start @ last word in cell.

is there overarching formula add comma before philadelphia , plymouth meeting?

here simple example can adapt use. have addresses in column a , city list in column b:

enter image description here

the following macro scans addresses looking [space][city] , replaces city [,][city]

sub commafication()    dim acol string, ccol string    dim ia long, ic long, va string, vc string  '''''''''''''''''''''''''''''''''''' '  update these needed acol = "a" ccol = "b" iamax = 3 icmax = 6 ''''''''''''''''''''''''''''''''''''     ia = 1 iamax       va = cells(ia, acol).text       ic = 1 icmax          vc = cells(ic, ccol).text          if instr(va, " " & vc) > 0             cells(ia, acol).value = replace(va, vc, "," & vc)          end if       next ic    next ia end sub 

here result:

enter image description here

note

this places comma before city name, requested, rather placing space between comma , city.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -