Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 244
Default Conversion of numbers

Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Conversion of numbers

1) I will assume there are always 2 digits before the first hyphen
2) You state:"However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256." I
will assume this should be 1/124
With the coded value (and Oh what a code!) in A1
In B1 we get the dollar amount with =--LEFT(A1,2)
In C1 we get the 32-th bit with =MID(A1,4,2)/32
In D1 we get the 1/124 bit or the 1/64 correction with
=IF(ISNUMBER(--MID(A1,6,1)),RIGHT(A1)/124,IF(RIGHT(A1)="+",1/64,IF(RIGHT(A1)="-",-1/64,0)))
And in E1 we get the total with =SUM(B1:D1)
I recommend you test this with more examples
I will leave it to use to combine all of this into one simple formula if so
desired
And I expect others to give a us nice VBA solution
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Arne Hegefors" wrote in message
...
Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are
quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price
is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract
1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Conversion of numbers

What a lovely typo
I will leave it to YOU ......
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Bernard Liengme" wrote in message
...
1) I will assume there are always 2 digits before the first hyphen
2) You state:"However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256." I
will assume this should be 1/124
With the coded value (and Oh what a code!) in A1
In B1 we get the dollar amount with =--LEFT(A1,2)
In C1 we get the 32-th bit with =MID(A1,4,2)/32
In D1 we get the 1/124 bit or the 1/64 correction with
=IF(ISNUMBER(--MID(A1,6,1)),RIGHT(A1)/124,IF(RIGHT(A1)="+",1/64,IF(RIGHT(A1)="-",-1/64,0)))
And in E1 we get the total with =SUM(B1:D1)
I recommend you test this with more examples
I will leave it to use to combine all of this into one simple formula if
so desired
And I expect others to give a us nice VBA solution
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Arne Hegefors" wrote in message
...
Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are
quoted
like this eg: 99-02. Now this means that the price is 99 and some
decimal.
The two first numbers are the number of 32:s. Thus in this case the price
is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract
1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot
in
advance!





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Conversion of numbers

Unless you want to create a User Defined Function....
Try something like this:

For a quoted price in A1

This formula converts the quote to a decimal value
B1:
=LEFT(A1,FIND("-",A1)-1)+MID(A1,FIND("-",A1)+1,2)/32+CHOOSE(MAX(COUNTIF(A1,{"*-???","*-??+","*-??-","*-???+","*-???-"})*{1,2,3,4,5})+1,0,RIGHT(A1,1)/124,1/64,-1/64,LEFT(RIGHT(A1,2),1)/124+1/64,LEFT(RIGHT(A1,2),1)/124-1/64)

(yeah....I know....it's not very pretty)

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"Arne Hegefors" wrote:

Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 244
Default Conversion of numbers

Thanks very much bernard. However the dollar amount (ie the non decimal
numbers) might be of one, two or three digits. Also the third decimal should
be 1/256. Please see top of page page 10:

http://www.newyorkfed.org/cfcbsweb/T...d_agencies.pdf

Thanks again Bernard!

"Bernard Liengme" skrev:

1) I will assume there are always 2 digits before the first hyphen
2) You state:"However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256." I
will assume this should be 1/124
With the coded value (and Oh what a code!) in A1
In B1 we get the dollar amount with =--LEFT(A1,2)
In C1 we get the 32-th bit with =MID(A1,4,2)/32
In D1 we get the 1/124 bit or the 1/64 correction with
=IF(ISNUMBER(--MID(A1,6,1)),RIGHT(A1)/124,IF(RIGHT(A1)="+",1/64,IF(RIGHT(A1)="-",-1/64,0)))
And in E1 we get the total with =SUM(B1:D1)
I recommend you test this with more examples
I will leave it to use to combine all of this into one simple formula if so
desired
And I expect others to give a us nice VBA solution
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Arne Hegefors" wrote in message
...
Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are
quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price
is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract
1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Conversion of numbers

Arne,

For a string in cell A2:

=VALUE(LEFT(A2,FIND("-",A2)-1))+VALUE(MID(A2,FIND("-",A2)+1,2))/32+IF((LEN(A2)-FIND("-",A2))=3,IF(MID(A2,FIND("-",A2)+3,1)="-",-1/64,IF(MID(A2,FIND("-",A2)+3,1)
= "+", 1/64,MID(A2,FIND("-",A2)+3,1)/256)))

I just wasn't sure how to interpret this:

"refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256."

Should it actually be divided by 124, or by 256 - I used 256 in the formula.

HTH,
Bernie
MS Excel MVP


"Arne Hegefors" wrote in message
...
Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Conversion of numbers

Per your reference to the treasury PDF file....

Try this:

A1: (a quoted price)

The decimal value would be
B1:
=LEFT(A1,FIND("-",A1)-1)+MID(A1,FIND("-",A1)+1,2)/32+CHOOSE(MAX(COUNTIF(A1,{"*-???","*-??+","*-??-","*-???+","*-???-"})*{1,2,3,4,5})+1,0,RIGHT(A1,1)/256,1/64,-1/64,LEFT(RIGHT(A1,2),1)/256+1/64,LEFT(RIGHT(A1,2),1)/256-1/64)

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

Unless you want to create a User Defined Function....
Try something like this:

For a quoted price in A1

This formula converts the quote to a decimal value
B1:
=LEFT(A1,FIND("-",A1)-1)+MID(A1,FIND("-",A1)+1,2)/32+CHOOSE(MAX(COUNTIF(A1,{"*-???","*-??+","*-??-","*-???+","*-???-"})*{1,2,3,4,5})+1,0,RIGHT(A1,1)/124,1/64,-1/64,LEFT(RIGHT(A1,2),1)/124+1/64,LEFT(RIGHT(A1,2),1)/124-1/64)

(yeah....I know....it's not very pretty)

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"Arne Hegefors" wrote:

Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Conversion of numbers

Ok...here it is....the best I could come up with:

B1:
=LEFT(A1,FIND("-",A1)-1)+SUM(LOOKUP(MID(A1,FIND("-",A1)+{1,2,3,4},1),{"","-","+","0","1","2","3","4","5","6","7","8","9"} ,{0,-4,4,0,1,2,3,4,5,6,7,8,9})/{3.2,32,256,256})

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

Per your reference to the treasury PDF file....

Try this:

A1: (a quoted price)

The decimal value would be
B1:
=LEFT(A1,FIND("-",A1)-1)+MID(A1,FIND("-",A1)+1,2)/32+CHOOSE(MAX(COUNTIF(A1,{"*-???","*-??+","*-??-","*-???+","*-???-"})*{1,2,3,4,5})+1,0,RIGHT(A1,1)/256,1/64,-1/64,LEFT(RIGHT(A1,2),1)/256+1/64,LEFT(RIGHT(A1,2),1)/256-1/64)

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Ron Coderre" wrote:

Unless you want to create a User Defined Function....
Try something like this:

For a quoted price in A1

This formula converts the quote to a decimal value
B1:
=LEFT(A1,FIND("-",A1)-1)+MID(A1,FIND("-",A1)+1,2)/32+CHOOSE(MAX(COUNTIF(A1,{"*-???","*-??+","*-??-","*-???+","*-???-"})*{1,2,3,4,5})+1,0,RIGHT(A1,1)/124,1/64,-1/64,LEFT(RIGHT(A1,2),1)/124+1/64,LEFT(RIGHT(A1,2),1)/124-1/64)

(yeah....I know....it's not very pretty)

Is that something you can work with?
***********
Regards,
Ron

XL2002, WinXP


"Arne Hegefors" wrote:

Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.
Is there any way that I can convert these price quotes into decimal form
using worksheet functions? Any help very much appreciated! Thanks a lot in
advance!

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Conversion of numbers

Arne Hegefors wrote...
Hi! I have a list with prices of US Treasury bonds. They are quoted in a
partcular way that I would like to convert to decimal form. They are quoted
like this eg: 99-02. Now this means that the price is 99 and some decimal.
The two first numbers are the number of 32:s. Thus in this case the price is
99 and 2/32. However if there are three decimals eg 99-021 the last digit
refers to the number of 124:s. Thus the price is 99 and 2/32 and 1/256.
Sometimes There are only two decimals followed by a plus or minus sign eg
99-30+ or 99-10-. The plus/minus indicates that you should add/subtract 1/64.

....

Yet another alternative.

=LEFT(x,FIND("-",x)-1)+MID(x,FIND("-",x)+1,2)/32+IF(COUNTIF(x,"*-???"),
CHOOSE(FIND(RIGHT(x,1),"+-"&RIGHT(x,1)),4,-4,RIGHT(x,1))/256)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Old Part Numbers with New Part Numbers in a Macro. Jeffery Keown Excel Discussion (Misc queries) 5 October 17th 06 03:45 PM
conditional formatting Lofty Excel Worksheet Functions 7 July 10th 06 09:06 PM
How to generate sets of random numbers without having duplicates William Excel Worksheet Functions 1 June 6th 06 05:30 AM
Why are 1/2 my numbers imported as text and the rest as numbers? KBear Excel Discussion (Misc queries) 2 April 21st 06 01:40 PM
Conversion of Dec numbers to Bin, Oct and Hex and visa versa xzl6pl Excel Discussion (Misc queries) 1 June 27th 05 12:15 PM


All times are GMT +1. The time now is 07:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"