How to Remove HTML Tags from Text in Excel: 2 Suitable Methods

Method 1 – Remove HTML Tags Using Find and Replace Tool

Steps:

  • Select the cells (B5:B9 here) where your texts with HTML tags are present.
  • Press Ctrl + H on your keyboard.

Access the Find and Replace Window to Remove HTML Tags from Text in Excel

  • The Find and Replace window will appear.
  • Go to the Replace tab >> insert <*> in the Find what: text box >> Leave a blank in the Replace with: text box >> click on the Replace All button.

Find and Replace Window to Remove HTML Tags from Text in Excel

  • A Microsoft Excel dialogue box will appear, showing you the information about replacements.
  • Click on the OK button.

Microsoft Excel Dialogue Box

Remove HTML tags from the texts in Excel and the final outcome would look like this.

Removed HTML Tags from Text in Excel


Method 2 – Use VBA Code to Remove HTML Tags from Text in Excel

Steps:

  • Go to the Developer tab >> Visual Basic tool.

Access the Visual Basic Tool

  • The VB Editor window will open.
  • Go to the Insert tab here >> click on the Module option.

Insert a Module to Remove HTML Tags from Text in Excel

  • A new module named Module1 will be created.
  • Go to Module1 >> insert the following code in the code window >> press Ctrl + S on your keyboard.
Sub RemoveHTMLTags()
    Dim lookupRange As Range
    Dim lookupCell As Range
    Dim lookupAddress As String
    On Error Resume Next
    lookupAddress = Application.ActiveWindow.RangeSelection.Address
    Set lookupRange = Application.InputBox("Select your data range", "Remove HTML Tags", lookupAddress, , , , , 8)
    Set lookupRange = Application.Intersect(lookupRange, lookupRange.Worksheet.UsedRange)
    If lookupRange Is Nothing Then Exit Sub
    lookupRange.NumberFormat = "@"
    With CreateObject("vbscript.regexp")
        .Pattern = "\<.*?\>"
        .Global = True
        For Each lookupCell In lookupRange
            lookupCell.Value = .Replace(lookupCell.Value, "")
        Next
    End With
End Sub

VBA Code to Remove HTML Tags from Text in Excel

  • A Microsoft Excel dialogue box will appear.
  • Click on the No button.

Microsoft Excel Dialogue Box

  • The Save As window will appear.
  • Choose the Save as type: option as .xlsm file and click on the Save button.

Save As Window

  • Close the VB Editor.
  • Go to the Developer tab >> Macros tool.

Access the Macros Tool to Remove HTML Tags from Text in Excel

  • The Macro window will appear.
  • Click on the RemoveHTMLTags macro and click on the Run button.

Run Macro to Remove HTML Tags from Text in Excel

  • The Remove HTML Tags window will appear.
  • Out cell reference B5:B9 in the Select your data range text box and click the OK button.

Remove HTML Tags Window

The HTML tags from your texts will be removed and you will get the desired output which should look like this.

Removed HTML Tags from Text in Excel


Download Practice Workbook

You can download our practice workbook from here for free.

HTML File:

Excel File:


Related Articles


<< Go Back To Data Cleaning in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Tanjim Reza
Tanjim Reza

Md. Tanjim Reza Tanim, a BUET graduate in Naval Architecture & Marine Engineering, contributed over one and a half years to the ExcelDemy project. As an Excel & VBA Content Developer, he authored 100+ articles and, as Team Leader, reviewed 150+ articles. Tanim, leading research, ensures top-notch content on MS Excel features, formulas, solutions, tips, and tricks. His expertise spans Microsoft Office Suites, Automating Finance Templates, VBA, Python, and Developing Excel Applications, showcasing a multifaceted commitment to the... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo