Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:52:29+00:00 2026-06-15T21:52:29+00:00

I am trying to write to a macro which remove html tags from excel

  • 0

I am trying to write to a macro which remove html tags from excel data.
I just want search for <*> this pattern and replace them with blank.
Also need to remove special characters like ‘“’and tags like if(typeof(dstb)!= “undefined”){ dstb();}.

Code I have written till now requires me to hardcode files name in macro , which I do not want.

code :

 Sub UnescapeCharacters()
 sheetname = "2011 Publications" 'file name goes here

Dim sheet As Worksheet
Set sheet = Me.Worksheets(sheetname)

For Row = 1 To sheet.UsedRange.Rows.Count
    For Column = 1 To sheet.UsedRange.Columns.Count
        Dim cell As Range
        Set cell = sheet.Cells(Row, Column)


        ReplaceCharacter cell, "&quot;", """" 
        ReplaceCharacter cell, "&#44;", ""
        ReplaceCharacter cell, "&nbsp;", ""
        ReplaceCharacter cell, "&bull;", ""

        ReplaceCharacter cell, "</ul>", ""
        ReplaceCharacter cell, "<ul>", ""

        ReplaceCharacter cell, "<b>", ""
        ReplaceCharacter cell, "</b>", ""

        ReplaceCharacter cell, "<i>", ""
        ReplaceCharacter cell, "</i>", ""

        ReplaceCharacter cell, "</li>", ""
        ReplaceCharacter cell, "<li>", ""

        ReplaceCharacter cell, "</br>", ""
        ReplaceCharacter cell, "<br />", ""

        ReplaceCharacter cell, "</p>", ""
        ReplaceCharacter cell, "<p>", ""

    Next Column
Next Row

End Sub

Sub ReplaceCharacter(ByRef cell As Range, ByVal find As String, ByVal replacement As     String)

Dim result As String
cell.Value = Replace(cell.Text, find, replacement, 1, -1)

End Sub

Can someone please help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:52:30+00:00Added an answer on June 15, 2026 at 9:52 pm

    I prefer doing it in this approach.
    If the HTML is NOT a real website, you can save the HTML as a file, then IE.navigate that filePath.

       Sub testing()
        Dim IE As Object
        Dim stringWithOutTags As String
        Set IE = CreateObject("InternetExplorer.Application")
            ' HardCode the URL address in
            IE.navigate "http://stackoverflow.com/questions/13824872/writing-macro-in-excel-to-remove-html-code"
            Do While IE.Busy
            Loop
            Do While IE.readyState <> 4
            Loop
    
    
            stringWithOutTags = IE.document.DocumentElement.innerText
    
            IE.Quit
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Word macro which inserts data from the Current User
I am trying to write a macro in Excel which will allow me to
I am trying to write a macro in VB for an Excel spreadsheet which
I am trying to write an excel macro/VBA code to adjust a column's contents
I'm trying to write a macro in Lisp that re-implements let using itself. This
I am trying to create a macro for an Excel file which has a
I'm trying to write an Excel macro using VBA to automate importing CSV text
I am trying to write a macro which pastes over the formulae within certain-named
I'm trying to run an Excel macro from outside of the Excel file. I'm
I'm trying to write a macro that builds middleware akin to that used in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.