Duplicates values when using the "&" to join results

Jonathan1726

New Member
Joined
Aug 27, 2019
Messages
2
Hello Guys, here is the situation:
I created a formula to extract the date on a string of text from any position, and I used the IF function to show the same value is the Date is not in the text.

Here is the example:

FORMULA:
=TRIM(IF(ISERROR(SEARCH("/",B14)),B14,LEFT(B14,SEARCH("/",B14)-3))&" "&IF(ISERROR(SEARCH("/",B14)),B14,RIGHT(B14,LEN(B14)-SEARCH("/",B14)-5)))

[TABLE="width: 591"]
<tbody>[TR]
[TD] Raw Data[/TD]
[TD] Clean Data[/TD]
[/TR]
[TR]
[TD]B14- Jose $250 12/06/16 OTR[/TD]
[TD] Jose $250 OTR[/TD]
[/TR]
[TR]
[TD]B15- 250 Josefa otr 1/05/29 Mac[/TD]
[TD] 250 Josefa otr Mac[/TD]
[/TR]
[TR]
[TD]B16- 12/25/89 OTR Windows $152[/TD]
[TD] OTR Windows $152[/TD]
[/TR]
[TR]
[TD]B17- Ana OTR Windows $152[/TD]
[TD] Ana OTR Windows $152 Ana OTR Windows $152 [/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
The problem is that because I used the & to join the results, it is repeating the results when it does not find a date on the text (see B17 Underlined). How can I fix this?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi & welcome to MrExcel.
Try
=TRIM(IF(ISERROR(SEARCH("/",B14)),B14,LEFT(B14,SEARCH("/",B14)-3))&" "&IF(ISERROR(SEARCH("/",B14)),"",RIGHT(B14,LEN(B14)-SEARCH("/",B14)-5)))
 
Upvote 0
Or,

=IFERROR(TRIM(REPLACE(B14,FIND("/",B14)-2,8,"")),B14)

Regards
Bosco
 
Upvote 0
In consider the data may have : "1/25/89 OTR Windows $152"

then, the above formula change to :

=IFERROR(TRIM(REPLACE(B14,MAX(1,FIND("/",B14)-2),8,"")),B14)

Regards
Bosco
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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