Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default General Field Format - Need to change to decimal

i'm downloading data into an excel spreadsheet from
bloomberg. bloomberg is a financial data provider.

the download is giving me prices in general format that
look like this. 99-27 3/4, 98-18, 103-16, 99-00 1/2.

basically 99-27 3/4 is equal to 99.8671875. you take the
fraction and 27 3/4 which is equals 27.75 and divide that
by 32. that gives you .8671875

is there any function in excel that will help me covert
the general number into decimal format. i need to change
all the general numbers into decimal format.

tks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default General Field Format - Need to change to decimal

I'd use a macro:

And I got these when I tested:

99.8671875 98.5625 103.5 99.015625


Option Explicit
Sub testme01()

Dim myCell As Range
Dim myRng As Range
Dim myStr As String
Dim mySplit As Variant
Dim myValue As Double

Set myRng = Selection

For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
'do nothing
Else
myStr = myCell.Value & " 0 0 0"
myStr = Application.Trim(Application.Substitute(myStr, "-", " "))
mySplit = Split97(myStr, " ")
myValue = mySplit(LBound(mySplit)) * 1 _
+ mySplit(LBound(mySplit) + 1) / 32 _
+ Application.Evaluate(mySplit(LBound(mySplit) + 2)) / 32
myCell.Value = myValue
End If
Next myCell

End Sub
'from Tom Ogilvy
Function Split97(sStr As Variant, sdelim As String) As Variant
Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") & """}")
End Function

If you're using xl2k or higher, you can delete the split97 function and change
the call to just Split(mystr," ") (Split was added in xl2k.)

And you could replace application.substitute with Replace (also added in xl2k).

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Select your range of cells
click on Tools|macro|macros...
click on the macro name (testme01--but you could rename it to something
meaningful!)
and then click run.


"R.Kim" wrote:

i'm downloading data into an excel spreadsheet from
bloomberg. bloomberg is a financial data provider.

the download is giving me prices in general format that
look like this. 99-27 3/4, 98-18, 103-16, 99-00 1/2.

basically 99-27 3/4 is equal to 99.8671875. you take the
fraction and 27 3/4 which is equals 27.75 and divide that
by 32. that gives you .8671875

is there any function in excel that will help me covert
the general number into decimal format. i need to change
all the general numbers into decimal format.

tks.


--

Dave Peterson

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
Decimal point in general format phoenix native Excel Worksheet Functions 1 August 11th 09 06:43 PM
Change General format to Date format Vic Excel Discussion (Misc queries) 2 May 2nd 09 09:41 AM
excel numbers in general format i cant add cant change format claude Excel Worksheet Functions 2 July 7th 06 08:18 PM
Change general format to US date format woodlot4 Excel Discussion (Misc queries) 3 October 11th 05 12:29 AM
Change General Format to Currency Format Freshman Excel Worksheet Functions 3 July 8th 05 03:42 AM


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

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

About Us

"It's about Microsoft Excel"