Reputation: 219
I have the following text in an excel cell:
SampleID: S-2016-011451 SubmitterID: EIROSSME Sample Name: T1 BTMs - 6/26/16 10:00 PM Lot Nbr: ProductID
:
I need to cut the data so that it reads as:
T1 BTMs 6/26/16 22:00
I can format the date using text($cell,"mm/dd/yy hh:mm") but I can't get the =mid(...) to truncate the data between "Name:" and " - ".
Upvotes: 0
Views: 41
Reputation: 8531
Use SUBSTITUTE
to change, so use SUBSTITUTE(a1,"Sample Name:","£££")
and SUBSTITUTE(a1,"PM Lot Nbr:","$$$")
together, then you'll get £££ T1 BTM......$$$ then you can find the instances of the £££ and $$$ and mid inbetween then, or RIGHT, then LEFT
This gives you the points to cut from and to. You can use the find of the values that we are also substituting, so find PM Lot Nbr etc.
SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","@@@"),"PM Lot Nbr","|||")
Something similar to this (not complete, I shall finish and tidy)
=MID(SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","@@@"),"PM Lot Nbr","|||"),LEN("@@@") + FIND("@@@",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","@@@"),"PM Lot Nbr","|||")),(FIND("|||",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","@@@"),"PM Lot Nbr","|||"))-FIND("@@@",SUBSTITUTE(SUBSTITUTE(J1,"Sample Name","@@@"),"PM Lot Nbr","|||"))-LEN("|||")))
Upvotes: 0
Reputation: 10450
Assuming you know what to expect after Sample Name:
=MID(A1,SEARCH("Sample Name:",A1)+13,7)
=MID(A1,SEARCH(A4,A1)+LEN(A4)+3,17)
And now you just have to convert the second cell to the date format you want (which you already know how) and concat them like A4&C4
(if C4
is the date after conversion).
Hope it helps ;)
Upvotes: 0
Reputation: 5157
1st: =mid(B2;63;26)
2nd: =mid(B5;1;8)
3rd: =mid(B5;11;18)
4th: =concatenate(B7;B8)
If you want to cut between Name:
and -
, just use:
=find("Name: ";B2)
=find(" -";B2)
and then:
=mid(B2, find("Name: ";B2)+5;find(" -";B2)-find("Name: ";B2)-5)
I.e.:
Upvotes: 1