Say I have a paragraph and I want to remove the one sentence in there with the phrase "ship" in it, and leave everything else in tact.
For example if I have the paragraph:
I like apples. And bananas. Free Shipping offered. I love cookies.
It would end up as:
I like apples. And bananas. I love cookies.
The way I imagine it working is using "instr" to find where "ship" is, and then finding the positions of the period immediately before and after it..then combining the sentences before and after it using LEFT and RIGHT functions.
So far I have:
public function newdesc(desc)
Dim p1 As Integer //p1 = position of period before "ship"
Dim p2 As Integer //p2 = position of period after "ship"
pos_ship = InStr(desc, "ship") //position of "ship"
If pos_ship > 0 Then
p2 = InStr(pos_ship, desc, ".")
Then I would end up with:
newdesc = left(desc, p1) & right(desc, len(desc) - p2)
But how do I define "p1"?
For example if I have the paragraph:
I like apples. And bananas. Free Shipping offered. I love cookies.
It would end up as:
I like apples. And bananas. I love cookies.
The way I imagine it working is using "instr" to find where "ship" is, and then finding the positions of the period immediately before and after it..then combining the sentences before and after it using LEFT and RIGHT functions.
So far I have:
public function newdesc(desc)
Dim p1 As Integer //p1 = position of period before "ship"
Dim p2 As Integer //p2 = position of period after "ship"
pos_ship = InStr(desc, "ship") //position of "ship"
If pos_ship > 0 Then
p2 = InStr(pos_ship, desc, ".")
Then I would end up with:
newdesc = left(desc, p1) & right(desc, len(desc) - p2)
But how do I define "p1"?
Last edited: