+ Reply to Thread
Results 1 to 11 of 11

Removing Line Breaks In A Cell

  1. #1
    Registered User
    Join Date
    01-25-2008
    Posts
    5

    Removing Line Breaks In A Cell

    Hi,

    I am trying to split cells that have addresses in them into separate cells via writing a formula but am having no joy, i wonder if anyone could help me please.

    What i need is to split cell A1 which contains an address i.e

    Red Roofs
    12 Chiltern walk
    Tunbridge Wells
    Kent
    TN1 1PL
    England

    I need to put a formula in cells B1,C1,D1,E1,F1 and G1 tha splits each line of the address and puts it in the separate cells so it would look like:

    B1 Red Roofs
    C1 12 Chiltern walk
    D1 Tunbridge Wells
    E1 Kent
    F1 Tn1 1pl
    G1 England

    Hope there is a way to do this and thankyou very much for your help

    Cheers

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Ross220681

    ...and welcome to the forum!!

    I came up with this code as a solution to a recent post. Can you use this?
    http://www.excelforum.com/showthread.php?t=629978

    Quote Originally Posted by DominicB
    Not fully tested this but it seems to work OK.

    Please Login or Register  to view this content.
    It works for 4 line addresses, thus (say your address is in cell A1) :
    =GetAddress1(A1,1) for line 1
    =GetAddress1(A1,2) for line 2 etc up to line 4

    You'll need to extend the code above to take account of 5 line addresses.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  3. #3
    Registered User
    Join Date
    01-25-2008
    Posts
    5
    Thats brilliant! i think that might be the way to go

    Sorry for being completly stupid, this is to be written in VB? or is this a formula?

    Thanks for your help

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867
    Hi Ross220681

    This is a custom function written in VBA. Pu the module into your workbook, and then use the formula as though it were a native function.

    Open the workbook in Excel and press Alt + F11. This will open the VBE.
    Select your workbook under the VBAProject window and go to Insert > Module and paste the code into the empty window that opens.
    Now go to File > Close and Return to Microsoft Excel. This will close the VBE.

    From within Excel you can now use these formulae in this workbook only :
    =GetAddress1(A1,1) for line 1
    =GetAddress1(A1,2) for line 2 etc up to line 4

    HTH

    DominicB

  5. #5
    Registered User
    Join Date
    01-25-2008
    Posts
    5
    Tried that out and thats brilliant your an absolute life saver!

    1 last question i promise, could you let me know what the code would be in VB if it was a 6 line address

    Thanks again

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Hi Ross,

    This type of question comes up time and time again and dominicb has given you a solution to it that works. Could you please change the title of your question from Help!!!!!!!!!! to something more suitable to what you are actually asking.

    http://www.excelforum.com/showthread.php?t=619135
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  7. #7
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Ross220681

    Quote Originally Posted by Ross220681
    could you let me know what the code would be in VB if it was a 6 line address
    Try this :
    Please Login or Register  to view this content.
    HTH

    DominicB

  8. #8
    Registered User
    Join Date
    01-25-2008
    Posts
    5

    Splitting Address in a cell

    No probs,

    If someone could help finish off this code in VB that would be great

    Many Thanks

  9. #9
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Ross220681

    Look at my last post.

    HTH

    DominicB

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Ross220681

    One more thing, make the second line of your function :
    Please Login or Register  to view this content.
    This will force an automatic recalculation of the function should the target cell change, the full modified function should read :
    Please Login or Register  to view this content.
    HTH

    DominicB

  11. #11
    Registered User
    Join Date
    03-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Removing Line Breaks In A Cell

    Awesome mate. That's exactly what I was loooking for

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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