+ Reply to Thread
Results 1 to 13 of 13

Text to Columns based on formatting

  1. #1
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Exclamation Text to Columns based on formatting

    Hello very helpful people

    I registered on this website because i saw you guys are extremely knowledgeable in excel.
    I am just beginning VBA and i have encountered a problem i cannot solve.

    I basically need text-to-column functionality delimited by formatting (Bold, Italics, normal)

    I have done my research and used the search feature and found threads such as
    http://www.ozgrid.com/forum/showthread.php?t=71459
    http://www.mrexcel.com/forum/excel-q...bold-text.html


    but the results were not working for me.

    My data is all in one column and is formatted like this
    #. Country Place of Employment Name - email@email.com [Date]


    What i want the result to be is each of these in their own column
    | #. | Country | Place of Employment | Name | email@email.com | [Date]


    I know how to do normal text-to-columns so the last few arnt a problem, but the first ones separated only by formatting is hard and i have no clue what to do.

    Thank you in advance!

    Cross-Post:
    http://www.mrexcel.com/forum/excel-q...ormatting.html
    http://www.ozgrid.com/forum/showthread.php?t=195819
    Last edited by VBAIsHard; 07-16-2015 at 02:29 PM.

  2. #2
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    I have adapted this solution and i think it's partially working.

    This seperates all the bold in A1 and then i change "Bold" to "Italic" and it separates all the italics character. I am almost at my goal.
    Credit to stanleydgromjr

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Text to Columns based on formatting

    In your pseudo-data you've defined both Place of Employment and Name in italics.
    How are you going to separate those?
    e.g.

    Royal Bank of Canada Fred Bloggs
    Bank of Montreal Bert Jones
    Imperial Oil Harry Paul Smith


    Each company has a different number of words making up their name so you can;t tell where the employee's name begins
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Quote Originally Posted by Special-K View Post
    In your pseudo-data you've defined both Place of Employment and Name in italics.
    How are you going to separate those?
    e.g.

    Royal Bank of Canada Fred Bloggs
    Bank of Montreal Bert Jones
    Imperial Oil Harry Paul Smith


    Each company has a different number of words making up their name so you can;t tell where the employee's name begins
    Yes i do wish to seperate those and that was a typo in the original post. Thank you for noticing it. I have fixed it. The name, email and date all have normal formatting

  5. #5
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Through the use of the above code in different configurations i have arrived with

    | Country | Name of Employment | #. Name - Email@Email.com [Date] |

    All in standard format. I think this has made the problem a lot easier. I just need to split up the last column (The first number field is useless), I just need to extract the name and email. They are separated by the "-" but the email could also have a "-" or a "." inside of it

  6. #6
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Book1.xlsx

    Sample data for anyone who wants to help. Thank you again

  7. #7
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    [Update] Text to columns using space delimiter gets me REALLY close to the solution. Only things i cant do is control the people with 1 or 3 words in their name.
    What could solve this is using the "-" in between the name and email to separate the two.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Text to Columns based on formatting

    Since this is in the nonVBA section, some formulas to "extract" the needed strings.

    D1: =LEFT(C1, FIND(".", C1)+2)
    E1: =TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," "))
    F1: =TRIM(LEFT(SUBSTITUTE(MID(C1, FIND("- ", C1)+2, 1000)," ", REPT(" ", 1000)), 500))
    G1: =MID(C1,FIND("[", C1), 20)

    Copy those down as needed, hide column C if you wish, or highlight columns D:G and do a COPY > PASTESPECIAL: Values, then delete column C.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Quote Originally Posted by JBeaucaire View Post
    Since this is in the nonVBA section, some formulas to "extract" the needed strings.

    D1: =LEFT(C1, FIND(".", C1)+2)
    E1: =TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," "))
    F1: =TRIM(LEFT(SUBSTITUTE(MID(C1, FIND("- ", C1)+2, 1000)," ", REPT(" ", 1000)), 500))
    G1: =MID(C1,FIND("[", C1), 20)

    Copy those down as needed, hide column C if you wish, or highlight columns D:G and do a COPY > PASTESPECIAL: Values, then delete column C.

    WOW! This is absolutly amazing! Thank you so much, i learned so much!!

  10. #10
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Quote Originally Posted by JBeaucaire View Post
    Since this is in the nonVBA section, some formulas to "extract" the needed strings.

    D1: =LEFT(C1, FIND(".", C1)+2)
    E1: =TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," "))
    F1: =TRIM(LEFT(SUBSTITUTE(MID(C1, FIND("- ", C1)+2, 1000)," ", REPT(" ", 1000)), 500))
    G1: =MID(C1,FIND("[", C1), 20)

    Copy those down as needed, hide column C if you wish, or highlight columns D:G and do a COPY > PASTESPECIAL: Values, then delete column C.
    If i have a cell containing: "word1 word2 word3"
    Is there a way to split it on the second space so i could have: | word1 word2 | word3 |

    Nevermind: https://support.office.com/en-ie/art...a-c35280be795d
    Last edited by VBAIsHard; 07-16-2015 at 02:29 PM.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Text to Columns based on formatting

    D1: =LEFT(C1, FIND(".", C1)+2)
    E1: =LEFT(TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," ")), FIND(" ", TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," "))))
    F1: =TRIM(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," ")), E1, ""))
    G1: =TRIM(LEFT(SUBSTITUTE(MID(C1, FIND("- ", C1)+2, 1000)," ", REPT(" ", 1000)), 500))
    H1: =MID(C1,FIND("[", C1), 20)

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  12. #12
    Registered User
    Join Date
    07-16-2015
    Location
    Toronto,Canada
    MS-Off Ver
    2013
    Posts
    9

    Re: Text to Columns based on formatting

    Quote Originally Posted by JBeaucaire View Post
    D1: =LEFT(C1, FIND(".", C1)+2)
    E1: =LEFT(TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," ")), FIND(" ", TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," "))))
    F1: =TRIM(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(C1,FIND(" -",C1)),D1,""),CHAR(160)," ")), E1, ""))
    G1: =TRIM(LEFT(SUBSTITUTE(MID(C1, FIND("- ", C1)+2, 1000)," ", REPT(" ", 1000)), 500))
    H1: =MID(C1,FIND("[", C1), 20)

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Thank you so much! I gave you reputation!
    I asked this question on 3 sites and bumped all day and you're the only one who offered help, you're awesome! I marked it as solved

  13. #13
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,652

    Re: Text to Columns based on formatting

    I asked this question on 3 sites
    Go to these sites and tell them you have a solution
    They will appreciate that.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Place text from multiple columns into one cell based on another columns value
    By minesht in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2015, 05:44 PM
  2. [SOLVED] I need to fill 2 text columns based on criteria from 2 adjacent columns
    By JohnnyBoyxxx in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-04-2014, 02:55 PM
  3. Compare text columns and return a value based on text
    By phxmafia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2014, 10:50 AM
  4. pull text from 2 columns based on finding text in other columns
    By jimcuk in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-03-2013, 09:21 AM
  5. Replies: 1
    Last Post: 08-28-2013, 09:07 AM
  6. [SOLVED] Conditional formating based on text in 2 columns (but only partial text!)
    By Icehockey44 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-19-2012, 06:26 AM
  7. [SOLVED] Conditional Formatting Columns Based on Text from Adjacent Column
    By mejiamang in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-18-2012, 10:41 PM

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