+ Reply to Thread
Results 1 to 10 of 10

Convert HTML in Excel Column to Plain Text

  1. #1
    Registered User
    Join Date
    10-21-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    4

    Convert HTML in Excel Column to Plain Text



    Hi,
    This is my first time posting to the forum. I've searched many threads here an have not found the answer I need.

    I am trying to build a spreadsheet based on data extracted from my SQL Server.

    What I have is a spreadsheet that is linked to a SQL View. The view contains several columns which are straight forward and not formatted when I pull the data into Excel (i.e. Ticket #, User Name, Date Created, etc.). However, the important column that contains the details of the support case is HTML formatted. So the data in that column appears something like this:

    "<div>Jim</div>
    <div>there were double receipts*in GP on*8/6</div>
    <div>I need to get them reversed.</div></div>"

    What I would like to see is:

    "Jim there were double receipts in GP on 8/6 I need to get them reversed."

    I just need that one column converted. I've tried everything I could think of and similar suggestions I've searched, but no luck.

    I can send more detail and examples if necessary.

    I appreciate any help provided.

    JL

  2. #2
    Valued Forum Contributor jj72uk's Avatar
    Join Date
    03-22-2008
    Location
    Essex, England
    MS-Off Ver
    Work - Office 2000, Home - Office 2007E
    Posts
    360

    Re: Convert HTML in Excel Column to Plain Text

    I needed something similar a little while ago and stumbled across this on a google group.

    All credit goes to Rick Rothstein.

    Orignal post can be found http://groups.google.com/group/micro...b8e6462c11746c


    In the VBA editor, add a UserForm to your project and put a TextBox and a
    CommandButton on it. Make the UserForm somewhat large in order to house a
    large TextBox and then make your TextBox large to fill all but enough room
    for the CommandButton. For the TextBox in the Properties window, set the
    MultiLine property to True and set the ScrollBars property to
    3-fmScrollBarsBoth. Now, copy/paste the following code into the UserForm's
    code window...


    '*********Start UserForm Code*********
    Please Login or Register  to view this content.
    '*********End UserForm Code*********


    Now we need some way to start this all off. For my test condition, I used
    the BeforeDoubleClick event of the Worksheet where your HTML text is going
    to be located, but you can change this to a button on the Toolbar or some
    other mechanism if you want. In the VBA editor, bring up the code window for
    the Worksheet you have your HTML text on and copy/paste the following into
    it...


    '*********Start Worksheet Code*********
    Please Login or Register  to view this content.
    '*********End Worksheet Code*********


    Now, simply double-click a cell with your HTML text in it and read the
    parsed content in the TextBox. When you are finished, click the
    CommandButton to dismiss the UserForm.

  3. #3
    Registered User
    Join Date
    10-21-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Convert HTML in Excel Column to Plain Text

    Thanks jj72uk.
    This worked great!
    However, I'd like to get the text inline and not have to click on the HTML and deal with the user form. Any way to do that?

    Jim

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Convert HTML in Excel Column to Plain Text

    Please Login or Register  to view this content.
    Last edited by shg; 10-21-2009 at 05:32 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    10-21-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Convert HTML in Excel Column to Plain Text

    shg,
    Unfortunately I am really not familiar with VBA. I don't know how to implement this code.
    Thanks.
    Jim

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Convert HTML in Excel Column to Plain Text

    Adding a Macro to a Code Module
    1. Copy the code from the post
    2. Press Alt+F11 to open the Visual Basic Editor (VBE)
    3. From the menu bar in the VBE window, do Insert > Module
    4. Paste the code in the window that opens
    5. Close the VBE to return to Excel

    Then select the range of interest, and run the macro. It will strip the tags in situ.

    Running a Macro
    1. Do Alt+F8 to open the macro dialog
    2. Select the macro name from the dropdown list and press Run

  7. #7
    Registered User
    Join Date
    10-21-2009
    Location
    San Diego
    MS-Off Ver
    Excel 2003
    Posts
    4

    Thumbs up Re: Convert HTML in Excel Column to Plain Text

    That is EXACTLY what I needed! Thank you SO much!
    Jim

  8. #8
    Valued Forum Contributor jj72uk's Avatar
    Join Date
    03-22-2008
    Location
    Essex, England
    MS-Off Ver
    Work - Office 2000, Home - Office 2007E
    Posts
    360

    Re: Convert HTML in Excel Column to Plain Text

    No problem, glad me and shg could help

  9. #9
    Registered User
    Join Date
    08-07-2014
    Location
    Opijnen
    MS-Off Ver
    2010
    Posts
    2

    Re: Convert HTML in Excel Column to Plain Text

    Hi,
    I used this macro also and it does the job great but I want to leave the html tag <CTRL> in the text.
    Can I exclude this?

  10. #10
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,445

    Re: Convert HTML in Excel Column to Plain Text

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

+ 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