View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Treasury Bond Pricing conversion

See inline comments...

=--(SUBSTITUTE(A1,"-"," ")&"/320")


Nifty!


Thanks


And this variation will distinguish between 2 and 3 digit
values after the dash...
=--(SUBSTITUTE(A1,"-"," ")&"/32"&IF(MID(A1,LEN(A1)-2,1)="-","","0"))


I had a similar thought after seeing your first follow-up. But for
defensive-programming purposes, I would suggest:

=--(SUBSTITUTE(A1,"-","
")&"/32"&IF(MID(A1,MAX(1,LEN(A1)-3),1)<"-","","0"))

That allows for the right part to be 1 digit as well as 2 or 3. I don't
know if that's necessary; I'm not familiar with the format of T-bond
prices, other than what Pakeez wrote. But the flexibility comes with no
cost, even if it is unnecessary.

(Well, almost "no cost". I put MAX(1,...) in at the last minute to handle
cases like 1-1.)


I think this would work as well (and it avoids the need for the MAX function
call)...

=--(SUBSTITUTE(A1,"-"," ")&"/32"&IF(LEN(A1)-FIND("-",A1)=3,"0",""))


Fun stuff! :-)


Yep! It sure is. ;-)


--
Rick (MVP - Excel)