i have list of city names followed state in located in 1 column in excel. how can delete after first space city name thing that's left in cell?
example: a1 = "johnson tx"
should a1= "johnson"
i assume want vba solution since tagged question excel-vba.
this works:
sub keepcity() dim strcityandstate string dim strcityonly string strcityandstate = range("a1").value strcityonly = left(strcityandstate, instr(strcityandstate, " ") - 1) range("a2").value = strcityonly end sub if don't want vba , want cell formula instead, @jtoland's answer works fine, though 1 more concise , doesn't keep trailing space character:
=left(a1, find(" ",a1)-1)
Comments
Post a Comment