+ Reply to Thread
Results 1 to 21 of 21

Extract data between html tags and place in new cells

  1. #1
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Extract data between html tags and place in new cells

    Hi, I have a cell in Excel that contains data that has text that I need to extract placed between <li> </li> tags. Example:

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
    <ul>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    </li>
    </ul>

    I would like the text between the <li> and </li> tags to be put into new columns in the same row while leaving the description in the original cell. I have about 10,000 lines to do and am hoping that there is a way to avoid doing these one at a time. Any help is truly appreciated!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Extract data between html tags and place in new cells

    Hi and welcome to the forum

    If you are talking about the 2nd set of text, try this...
    =MID(A1,SEARCH(">",A1,1)+1,LEN(A1)-9)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Extract data between html tags and place in new cells

    I'd advice to use VBA instead of a formula.
    Try this (untested) code - it should work...

    Please Login or Register  to view this content.
    Please click the * below if this helps
    Please click the * below if this helps

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extract data between html tags and place in new cells

    Or this:

    =IF(LEN(A1)>6,MID(A1,5,LEN(A1)-9),"")
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    The VBA macro seems to be the best solution however I was not able to get it to work, when I pasted it into a new module and ran it nothing happened.

    The 2 formulas did move the items to the next cell but did not strip the HTML or separate each bullet into a new cell.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Extract data between html tags and place in new cells

    How do you define a new bullet? It is not clear from your post

  7. #7
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    My apologies, a bullet is defined as any text between the <li> and </li> tag in the original post.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Extract data between html tags and place in new cells

    Assuming the data in col.A
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    This caused a "Runtime Error 429, activeX component can't create object". When I selected "Debug", the line highlighted was With CreateObject("VBScript.RegExp")

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Extract data between html tags and place in new cells

    You don't normally need to do this,but try set the reference to

    Microsoft VBScript Regular Expressions x.x

    While you are in VBE, go to [Tools] - [Reference] then tick the box.
    Attached Files Attached Files

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Extract data between html tags and place in new cells

    Quote Originally Posted by jsz View Post
    Hi, I have a cell in Excel that contains data that has text that I need to extract placed between <li> </li> tags. Example:

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
    <ul>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    <li>need this bullet point extracted and put into a new column</li>
    </li>
    </ul>

    I would like the text between the <li> and </li> tags to be put into new columns in the same row while leaving the description in the original cell. I have about 10,000 lines to do and am hoping that there is a way to avoid doing these one at a time. Any help is truly appreciated!
    The only <li> I see in your post are those that I bolded?

  12. #12
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    FDibbins - That is correct, the ones you bolded.

    Jindon - I will try your file tomorrow morning when I get into work and follow up with you. Thank you.

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Extract data between html tags and place in new cells

    So just copy the formula down?

    =MID(A1,SEARCH(">",A1,1)+1,LEN(A1)-9)

  14. #14
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    That doesn't solve the issue though, what that is doing is moving all of the data between the <li> and </li> tags into a new cell together, what I need is each data set between <li> and </li> to be extracted and moved into its own cell. Please accept my apologies if I didn't make that clear in my original post.

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Extract data between html tags and place in new cells

    OK sorry, could you show me an example in a workbook of what your expected outcome would be?

  16. #16
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    Figured it out, attached below
    Last edited by jsz; 09-05-2013 at 08:49 PM. Reason: Typo

  17. #17
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    Sample Workbook.xlsx

    This is what I would like the outcome to be.

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Extract data between html tags and place in new cells

    My file is doing exactly how you want ...

  19. #19
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    Jindon, I will check on my office computer in the morning, I am on office 2011 on a mac at home and I suspect that's the issue. I am on 2013 at work.

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,517

    Re: Extract data between html tags and place in new cells

    Or this should do the same
    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    08-23-2013
    Location
    VA USA
    MS-Off Ver
    Excel 2013
    Posts
    14

    Re: Extract data between html tags and place in new cells

    That did it! Thank you so much!!!

+ 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. Extract Data between tags in Excel Cell and place in new columns
    By interwoven in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2013, 06:15 PM
  2. extract information from webpage html tags to excel
    By b.hill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2012, 01:24 AM
  3. convert formated excel column to html source text with html tags
    By julia81 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-19-2011, 04:22 PM
  4. Removing HTML tags from cells
    By rochdalemark in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-22-2005, 06:09 AM
  5. Replies: 3
    Last Post: 01-13-2005, 08:06 PM

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