Hi all, new to the forums but from the brief look i've had looks like i'll be here quite a lot :-)
On to what brought me here; I have a spreadsheet with a column containing an address, eg '12 SMITH ST SOMESUBURB NSW 2001'. I'm looking at splitting this cell in half after the street and moving the second half (suburb state postcode) into the next cell, which i've managed to do with a series on InStr statements. Now the fun part is that not all these addresses are streets, some are avenues (AV or AVE), roads (RD), place (PL), drive (DR or DRV) etc. Initially i just did this:
If InStr(str1, " ST ") <> 0 Then 'if foundpos = InStr(str1, " ST ") + 2 'increment start point to allow for 2 letter end
Sheet2.Cells(sh2Row, sh2Col) = Left(str1, pos) 'write the start contents to the cell
End If
sh2Col = sh2Col + 1 'move to next cell
pos = pos + 2 'increment start point to allow for 2 letter start
Sheet2.Cells(sh2Row, sh2Col) = Mid(str1, pos) 'write the remainder to the cell
sh2Col = sh2Col + 1 'move to next cell
... with the 'If' statement being expanded for 'AV' and 'RD' etc as needed. But of course when you have 50+ possible street types to scan for this isn't the most efficient. I'm thinking this is a good place for a loop that reads in each of these possible street types and once found splits and moves it to the next cell before moving on. Just how i do this is where i could do with some help. Other things i have to deal with is that not all the street typed are 2 digits, 'AVE' is 3, 'COVE' is 4...
Any help would be much appreciated :-)
Bookmarks