Removing data after finding text in cell

pnjfksx

New Member
Joined
Jan 30, 2003
Messages
34
I am running a VBA macro on a spreadsheet and I need to remove some HTML <.span> tags. In my case, I want to delete everything from the first bracket of "<.span" to the last bracket of "<./span>", including the content between the tags. Any ideas on a quick way to do this?

Thanks!

Sorry, the system interpreted my HTML span tags and didn't display them. I have now placed dots in the tags to get them to show.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
How about something like this. Sheet1!A1 is the cell with the tags in this example. Dave
Code:
Private Sub CommandButton1_Click()
Dim strtest As String, flag As Boolean, newstring As String
Dim temp As Integer, i As Integer
strtest = [sheet1!A1]
flag = False
For i = 1 To Len(strtest)
  If flag = False Then
  temp = Asc(Mid(strtest, i, 1))
  If temp = 34 Then
  flag = True
  End If
  newstring = newstring + Mid(strtest, i, 1)
  End If
  Next i
[sheet1!A1] = newstring
End Sub
edit: whoops
 
Upvote 0

Forum statistics

Threads
1,203,472
Messages
6,055,612
Members
444,803
Latest member
retrorocket129

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