Hey all,
I have an excel spreadsheet that contains entire addresses packed in a single cell without delimiters. The addresses look like this:
2701 NW 64TH TER MARGATE FL 33063-1703
901 NE 8 ST HALLANDALE BEACH FL 33009-2626
1840 DEWEY ST UNIT 305 HOLLYWOOD FL 33020
3049 NE 4 AVE WILTON MANORS FL 33334-2047
650 NE 56 CT OAKLAND PARK FL 33334-3528
So the first five cells in column A would contain the above addresses.
As you can see, some of the cities consist of two words but the state is always FL or NY. All I need to do is separate the address, city, state, and zip in their own columns. I'm hoping there's a way to do this in VBD (Visual Basic for Developers) in excel. So I can put it into a macro.
I have an idea of how it can be done, but my VBD is limited:
stateArray = Split("FL, NY")
cityArray = Split("Fort Lauderdale","Sunrise","Oakland Park")
For example, another programming language you might do something like this:
var arrStates, arrCities
arrCities = ["Fort Lauderdale", "Sunrise", "Oakland Park"]
arrStates = ["FL", "NY"]
var findAddress = function(curCity, curState){
for(var i=0; i < arrCities.length; i < arrStates.length; i--){
(arrCities[i] == curCity) ? arrCities[i] = CurCity : arrCities[i] = null;
(arrStates[i] == curState) ? arrStates[i] = curState : arrStates[i] = null;
}
if(arrCities[i] >= 0){
var city = arrCities[i];
}
if(arrStates[i] >= 0){
var state = arrStates[i];
}
createTable(city, state);
}
var createTable = function(city, state){
var tbl = document.createElement("Table");
var newRow = document.createElement("tr");
tbl.appendChild(newRow);
cols = [city, state];
for(var i=0; i < cols.length; i++){
var newCol = document.createElement("td");
newCol.innerText = cols[i];
newRow.appendChild(newCol);
}
}
Thanks for any response.