I have a Data with HTML tags in excel sheet like below:
This is test data
Nice
Go on this is next Cell
Very goood ...
Since the macro above didn't work for me I fixed it myself. It's my first script, if you guys can improve it, make it faster, add more then you're more than welcome!
Ok guys, I've had no previous experience programming (except for some very basic Java 6 years ago) but with some help, lots of guessing (hours actually) I managed to make this script, it works like a charm to remove most and 8#text but it does not replace with linebreak (you can do this by hitting CTRL + H, "find: " "replace: (now hold ALT down and use type 0010 with your NUMPAD. A small dot should be blinking in the replace window, then hit "replace all").
Paste the code below into a user module (alt +f11, right click Sheet1->insert->Module->paste code)
And make a button by going File->Options->Customize Ribbon-> check the Developer checkbox. Then go to developer tab->Insert->Button-> then place the button and right click->assign macro-> Choose RemoveTags.
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(.Replace(r.Value, ""), "’", " ")
r.Value2 = Replace(.Replace(r.Value2, ""), "–", " ")
Next r
For Each r In Selection
r.Value = Replace(.Replace(r.Value, ""), "‘", " ")
r.Value2 = Replace(.Replace(r.Value2, ""), "
", " ")
Next r
For Each r In Selection
r.Value = Replace(.Replace(r.Value, ""), "
", " ")
r.Value2 = Replace(.Replace(r.Value2, ""), "s", " ")
Next r
End With
End Sub
Private Sub CommandButton1_Click()
End Sub