Remove HTML tags from text string - VBA

Fester675

Board Regular
Joined
Sep 16, 2016
Messages
141
I've done the above via this code - however how would I change this, so when one string ends the next is entered into a new cell (basically separate by each 'item')?

Sub RemoveTags()
'updateby Extendoffice 20160202
Dim xRg As Range
Dim xCell As Range
Dim xAddress As String
On Error Resume Next
xAddress = Application.ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("please select data range", "Kutools for Excel", xAddress, , , , , 8)
Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange)
If xRg Is Nothing Then Exit Sub
xRg.NumberFormat = "@"
With CreateObject("vbscript.regexp")
.Pattern = "\<.*?\>"
.Global = True
For Each xCell In xRg
xCell.Value = .Replace(xCell.Value, "")
Next
End With
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Is the selection your user makes before running this macro along a single row (across multiple columns) and you want each of those cells split downward? If not, please explain your existing data layout and how the split out values are to be placed into "new cells".
 
Upvote 0
Please bear with me on this - complete novice!
Ok so, a mass data extraction is happening imminently from an old sharepoint site for performance reports and in the 'Objectives' and 'Goals' sections, users could enter as many as they wanted. However on extraction to excel the free-format text would obviously include HTML tags. Now the string for <=1 will be...

<?xml version="1.0" encoding="utf-8"?>
<RepeaterData>
<Version />
<Items>
<Item>
<Development_Item type="System.String">
**PDP ITEM 1 here… FREE TEXT***
</Development_Item>
</Item>
</Items>
</RepeaterData>

For >1 section it will be...

<?xml version="1.0" encoding="utf-8"?>
<RepeaterData>
<Version />
<Items>
<Item>
<Development_Item type="System.String">
**PDP ITEM 1 here…FREE TEXT***
</Development_Item>
</Item>
<Item>
<Development_Item type="System.String">
**PDP ITEM 2 here…***
</Development_Item>
</Item>
</Items>
</RepeaterData>

So in the first tags, the VBA will be fine. But for the second tags, following the "</Item> the text needs to be put into the next cell down in the same column.
Hope this makes sense - my problem is I haven't physically got the extraction yet. I'm trying to build it prior to receiving the data.

TIA Rick.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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
Back
Top