Results 1 to 8 of 8

Splitting a cell string depending on variables

Threaded View

  1. #1
    Registered User
    Join Date
    03-01-2009
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Splitting a cell string depending on variables

    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 found
    pos = 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 :-)
    Last edited by Dave_09; 03-02-2009 at 10:36 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1