Complex MID +Find

rdev

Active Member
Joined
Dec 3, 2007
Messages
273
Hi I have tried hard butt got stuck finally
I have the following string in Cell A1 ,
ZAR 1676979125 I FFVV 24FEB11 | 4715 2747 | 0.50 24− 4− | 28− CCCA513101XXXXXX6557
I want to break up so that I have in cell B1, C1, D1 etc..
ZAR
1676979125
I
FFVV
24FEB11
4715 ( this can vary in terms of character, it is a currency amount)
2747( this too can vary , it is a currency amount
0.5
24
4
28
Can someone help me , i am a trouble getting this right
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try,

B1, copy across & down...

=TRIM(MID(SUBSTITUTE(" "&TRIM(SUBSTITUTE(SUBSTITUTE($A1,"−",""),"|",""))," ",REPT(" ",250)),COLUMNS($B1:B1)*250,250))
 
Upvote 0
Thanks Haseeb
Amazingly easy for you ,for me not , can you explain to me the formula you used
 
Upvote 0
" "&TRIM(SUBSTITUTE(SUBSTITUTE($A1,"−",""),"|",""))

This part will remove all the '−', '|' & extra spaces from the text, and add a space at the beginning. so you will get

" ZAR 1676979125 I FFVV 24FEB11 4715 2747 0.50 24 4 28 CCCA513101XXXXXX6557"

SUBSTITUTE(" "&TRIM(SUBSTITUTE(SUBSTITUTE($A1,"−",""),"|",""))," ",REPT(" ",250))

This will change all the space to 250 extra spaces.

MID(SUBSTITUTE(" "&TRIM(SUBSTITUTE(SUBSTITUTE($A1,"−",""),"|",""))," ",REPT(" ",250)),COLUMNS($B1:B1)*250,250)

COLUMNS($B1:B1) will give you 1, so 1*250 = 250

On B1 MID function start_num will set as 250, num_chars 250.

After each item you have 250 extra spaces. " ZAR " (250 space ZAR 250 space) so on for all items.

TRIM(MID.....) will remove the extra spaces.

When copy to C1, COLUMNS($B1:C1)*250 will give, 2*250 = 500,

MID start_num 500, num_chars 250. TRIM will remove the extra spaces. so on....

I am sorry if it is not clear :)
 
Upvote 0
You could also get very close with Data|Text to Columns|Delimited using space and "|" as the delimiters. It would leave the trailing "-" after those numbers which may be a problem, though you could use Find/Replace afterwards to remove those.
 
Upvote 0

Forum statistics

Threads
1,224,558
Messages
6,179,512
Members
452,920
Latest member
jaspers

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