remove anything between two strings in vba

starlev

New Member
Joined
Feb 21, 2016
Messages
27
I’m looking to build code to remove anything between two strings in vba.


For example anything between .

<iframe

And

</iframe>




For example my original string is


VBA Code:
<div class="col-md-6 col-xs-12 noPadLeft">

<iframe class="produ" src="gmail.com" allowfullscreen="" width="600" height="600" frameborder="0">

</iframe>

</div>



And the new string I would like is
VBA Code:
<div class="col-md-6 col-xs-12 noPadLeft">
</div>


How can this be done?

Is there way to do this with a regular expression?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I guess in your code the possibility of <iframe and </iframe to be on the same row is nil, right? This would be simpler handle. If not, you can use Instr to find start (<iframe) and end (</iframe) position and remove anything in between.

Instead of RegEx which is not native to VBA, Like can be used also, I suppose.
 
Upvote 0
Does the existing text have multiple Line Feeds like your example shows?

For the output you want, do you want the multiple Line Feeds removed like your example shows?

Is it possible for the delimiter tags and their included text that you want removed to appear more than once in your existing text?
 
Upvote 0
Also ..
Where is the original string? Is it in a worksheet cell? Is it held in a vba string variable? (not likely I guess with those internal quotes). Somewhere else?
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

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