Delete everything between two text lines in a variable

neqkeet

New Member
Joined
Nov 21, 2016
Messages
15
I'm trying to delete a text between two text lines in a variable "RangeToHtml". I want to delete everything between
PHP:
<![if supportMisalignedColumns]>
and
PHP:
<![endif]>
, which present only once in the whole code.


PHP:
<![if supportMisalignedColumns]> 
  <tr height=0 style='display:none'>
  <td width=76 style='width:57pt'></td>
  <td width=216 style='width:162pt'></td>
  <td width=113 style='width:85pt'></td>
  <td width=120 style='width:90pt'></td>
  <td width=56 style='width:42pt'></td>
 </tr>
 <![endif]>


I've tried to use the code below, which gave me no result.
PHP:
RangetoHTML = Replace(RangetoHTML, "<![if supportMisalignedColumns]>*<![endif]>", "")
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code:
Dim startChar As Long
Dim endChar As Long

startChar = InStr(1, RangetoHTML, "<![if supportMisalignedColumns]>")
endChar = InStr(startChar, RangetoHTML, "<![endif]>")

RangetoHTML = Left(RangetoHTML, startChar - 1) & Mid(RangetoHTML, endChar + 10)

WBD
 
Last edited:
Upvote 0
what about if you do:

Wv6aCJA.png
 
Last edited:
Upvote 0
You could also try
Code:
RangeToHtml = Split(RangeToHtml, "<![if supportMisalignedColumns]>")(0) & Split(RangeToHtml, "<![endif]>")(1)
 
Last edited:
Upvote 0
The problem with this is if <![endif]> also appears before the first string.
Perhaps I misinterpreted ..
.. and
PHP:
<![endif]>
, which present only once in the whole code.

If what you suggest is possible then we can still do it with a similar method
Code:
RangeToHtml = Split(RangeToHtml, "<![if supportMisalignedColumns]>")(0) & Split(Split(RangeToHtml, "<![if supportMisalignedColumns]>")(1), "<![endif]>")(1)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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