I have a string with the following format:
StockCode Country Date Price equity
for example:
1 hk 10/31/12 C70.5 equity
101 hk 11/21/13 P63 equity
388 hk 10/17/12 P100 equity
I can extract Date by this Excel Command:
LEFT(RIGHT(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)),
LEN(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))-FIND(" ",
RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))),FIND(" ",
RIGHT(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)),
LEN(RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1)))-FIND(" ",
RIGHT(LEFT(A1,LEN(A1)-7),LEN(LEFT(A1,LEN(A1)-7))-FIND(" ",A1))))))
(line breaks for readbility)
result: 10/31/12
Anyone has a better solution for this?
here are some of my codes:
how to get "C" and "P":
TRIM(MID(A1,IFERROR(FIND("P",A1),FIND("C",A1)),1))
how to get the strike price:
TRIM(SUBSTITUTE(RIGHT(A1,LEN(A1)-IFERROR(FIND("P",A1),
FIND("C",A1))),"equity",""))
The Microsoft Excel SPLIT function will split a string into substrings based on a delimiter. The result is returned as an array of substrings. The SPLIT function is a built-in function in Excel that is categorized as a String/Text Function. It can be used as a VBA function (VBA) in Excel.
Try this, I think it should work for all dates with a 2 character year:
=TRIM(MID(A1,FIND("/",A1)-2,8))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With