Removing HTML tags (specifically <p> tags)

furiousbob

New Member
Joined
Jul 2, 2015
Messages
2
Hi!


I'm new here. This would be my first post. I am in dire need of some help with removing HTML tags from a CSV file. I have about 3600 entries to modify. I used:


Code:
Sub RemoveTags()
Dim r As Range
Selection.NumberFormat = "@"  'set cells to text numberformat
With CreateObject("vbscript.regexp")
  .Pattern = "\<.*?\>"
  .Global = True
  For Each r In Selection
    r.Value = .Replace(r.Value, "")
  Next r
End With
End Sub

But that left me with about 880 entries with:

p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:normal"
<p class="MsoNormal" style="[/CODE]
p class=" msonormal"=""

(with < and > at the ends, not sure why I can't post it with the CODE tags)

I also tried find and replace using <*> for find and a empty replace field but I get the "Formula is too long" error message.


I'm pretty new to VBA so any help is appreciated!</p>
 
Last edited:

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,316
Members
414,053
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top