2

If you want to delete html tags in excel one way is to use the replace function. I search for "<*>" and replace it by "". So I just delete every html tag. Excel VBA also has a replace function but it is far more stupid. If I write:

temp2 = Replace(temp2, "<*>", "")

It doesn't interpret "< * >" as a regular expression. It only replace 1:1 the string "<*>". How can I use the replace function in VBA like I do in Excel?

Flex Texmex
  • 1,074
  • 2
  • 11
  • 23
  • possible duplicate of [excel formula to strip html](http://stackoverflow.com/questions/3135046/excel-formula-to-strip-html) –  Sep 02 '15 at 10:36
  • There's also the ability to use regular expressions in vba. See http://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops – MiguelH Sep 02 '15 at 10:42
  • 2
    If you would have recorded a macro, you would have got your answer... ;) – Siddharth Rout Sep 02 '15 at 10:43

1 Answers1

4

To search and replace all cells in the active sheet, you need to use something like:

Cells.Replace What:="<*>", Replacement:="", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

Note that you can indicate the cell directly in the beginning: Cells(2,1). (to only replace in the A2 cell.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563