Remove 3 letters from each text string

BlackieHamel

Board Regular
Joined
May 9, 2014
Messages
93
Friends,

I need this for a word puzzle I'm making. I have a list of 6-letter words that all contain SOU, and I want to strip out the SOU to find the remainder. But there's a twist. I need to think of these 6-letter words written underneath each other, so the SOU position in the 6-letter word may be written forward or backward, and even part at the beginning and part at the end of a word. In all cases, the SOU will appear, in that order, as the top half and the trigram I'm looking for is the remaining 3 letters. Thus, XES OUT can be written
SOU
EXT
reading clockwise, so the "correct answer" is EXT. Using a kind-of made-up word, AQUOSE, it could also be counterclockwise:
SOU
EAQ

. . . and the answer should read EAQ.

Is there a way I can do this with a formula that can then be copied? My examples don't always include SOU, and sometimes there are hundreds of possibilities, so I'm looking for a formula I can just "copy down."

Here are more examples of successful 3-letter transformations, given the 6-letter words in the first column.
SOURONNOR
SOUTERRET
OUSELSLES
SOUSEDDES
XESOUTEXT

<tbody>
</tbody>
AQUOSE EAQ

I don't even know if this is possible in Excel, but if someone knows how, I bet they're here in MrExcel. Thanks!

Blackie

<tbody>
</tbody>
 
Let me check if I understood this problem correctly!

BSOULE should yield BEL.
DSOUCA should yield DAC.
EFUOSX should yield FEX.

Am I right?
 
Last edited:
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this:

Excel 2012
ABCDEFGHIJ
1SOURON654NORNOR1654SOURON
2SOUTER654RETRET2165ASOUBC
3OUSELS543LESLES3216ABSOUC
4SOUSED654DESDES4321ABCSOU
5XESOUT216EXTEXT5432UABCSO
6AQUOSE612EAQEAQ6543OUABCS

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C1=IFERROR(MID("54321654",7-SEARCH("SOU",A1&A1),3),MID("45612345",SEARCH("UOS",A1&A1),3))
D1=MID(A1,LEFT(C1),1)&MID(A1,MID(C1,2,1),1)&MID(A1,RIGHT(C1),1)

<tbody>
</tbody>

<tbody>
</tbody>



There are really only 12 cases to consider. 6 cases where you find SOU in the initial word starting at positions 1,2,3,4,5,6, and 6 more where it's reversed and you look for UOS instead. So I just looked at the different cases and determined which letters you want in each of those cases. The table I made in H1:J6 shows the results for the SOU cases. So on row 1, if SOU is found in the first position, the letters you want in order are the ones in positions 6,5,4. The other cases are the same. If SOU is not found then we look for UOS, and the table for UOS is the same as SOU except reversed. And as you can see, there's a definite pattern to the numbers.

So for SOU I made a "master" pattern of all the numbers. I search for SOU in the word (the word doubled, in case SOU wraps), find the position, and get the number pattern from the master pattern. If it's not found, I try with UOS. That's the formula in C1. Then the formula in D1 merely extracts the letters from the original word in the required order.

It's likely that this could be simplified further, either with formulas or VBA, but for now this should work. Maybe someone else following this thread can improve on it.
 
Last edited:
Upvote 0
Perhaps, array formula**:

=TEXTJOIN(,1,IFERROR(MID(A1&A1,FIND(MID(CONCAT(MID(B$1,{1,2,3;3,2,1},1)),{1,4},3),A1&A1)+{5,3;4,4;3,5},1),""))

Regards


**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
 
Upvote 0
I should've mentioned that this formula goes in e.g. C1, with your first 6-letter word in A1 and your choice of 3-letter word (e.g. "SOU") in B1. Copy down to give similar results for words in A2, A3, etc.

Regards
 
Upvote 0

Forum statistics

Threads
1,216,590
Messages
6,131,614
Members
449,658
Latest member
JasonEncon

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