Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
convert fractions to decimals
Does anyone kow if you can convert the following fraction to a decimal
automatically. 7/8 x 2 1/4? Thanks in advance, I will score big brownie points with the boss if we can figure this one out :) |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
convert fractions to decimals
Where are these fractions? Are they in separate cells? Or is it in one
cell just like that (7/8 x 2 1/4)? If that is the case, then technically, it is not a fraction, but text. Separate cells and actual fractions?...change the cell format to Number. Regards, Paul -- "Shannon" <Shannon @discussions.microsoft.com wrote in message ... Does anyone kow if you can convert the following fraction to a decimal automatically. 7/8 x 2 1/4? Thanks in advance, I will score big brownie points with the boss if we can figure this one out :) |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
convert fractions to decimals
Can you use a macro? If so, you can have your macro call this subroutine...
Sub Solve(R As Range) Dim C As Range For Each C In R C.Value = Application.Evaluate(Replace(LCase$(C.Value), "x", "*")) Next End Sub Simply have your macro pass in the range of cells you want to convert from fractional calculations to numerical values. Something like this... Sub TestMacro() Solve Range("D10:D12") End Sub Note, as long as you use either "x", "X" or "*" for multiplication, "/" for division, "+" for addition and "-" for subtraction, coupled with lots of other functions (such as Sin, Sqrt, etc.) and parentheses, you can do quite complicated calculations with it. Rick "Shannon" <Shannon @discussions.microsoft.com wrote in message ... Does anyone kow if you can convert the following fraction to a decimal automatically. 7/8 x 2 1/4? Thanks in advance, I will score big brownie points with the boss if we can figure this one out :) |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
convert fractions to decimals
Thank you very much, I have teach myself macros first, LOL. Hopefully this
weekend. Thanks again, Shannon "Rick Rothstein (MVP - VB)" wrote: Can you use a macro? If so, you can have your macro call this subroutine... Sub Solve(R As Range) Dim C As Range For Each C In R C.Value = Application.Evaluate(Replace(LCase$(C.Value), "x", "*")) Next End Sub Simply have your macro pass in the range of cells you want to convert from fractional calculations to numerical values. Something like this... Sub TestMacro() Solve Range("D10:D12") End Sub Note, as long as you use either "x", "X" or "*" for multiplication, "/" for division, "+" for addition and "-" for subtraction, coupled with lots of other functions (such as Sin, Sqrt, etc.) and parentheses, you can do quite complicated calculations with it. Rick "Shannon" <Shannon @discussions.microsoft.com wrote in message ... Does anyone kow if you can convert the following fraction to a decimal automatically. 7/8 x 2 1/4? Thanks in advance, I will score big brownie points with the boss if we can figure this one out :) |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
convert fractions to decimals
Let's see if we can get you started at least. Start Excel and go to the
worksheet that has your "fractions" on it. Now, right-click the worksheet's tab at the bottom of the page and select View Code from the popup menu that appears. This will take you to the VB editor, and specifically, to the code window for the worksheet you were on when you right-clicked the tab. Copy/Paste the following code into that code window... ' ***** Start of Code ***** Sub Solve(R As Range) Dim C As Range On Error Resume Next For Each C In R C.Value = Application.Evaluate(Replace(LCase$(C.Value), "x", "*")) If IsError(C.Value) Then C.Clear Next End Sub Sub SolveCellExpressions() Solve Range("A1:A10") End Sub ' ***** End of Code ***** Okay, now go back to the worksheet (click File/Close and Return to Microsoft Excel on the VB editor's menu bar). Type some of your "fractions" and other expressions (remember, they can be more complicated than simple fractions if desired) that you want converted into any of the cell in the range A1:A10 (notice, that is the range specified in the subroutine named SolveCellExpressions). Here are some to get you started... A1: 7/8 x 2 1/4 A2: Sqrt(1/4) A3: Sin(0.523598775598299) + 1 1/2 {Answers.... A1 = 1.96875, A2 = 0.5, A3 = 2} Once you have typed as many expressions as you want in the first 10 cells of Column A, press Alt+F8 and select SolveCellExpressions from the list that appears. Next click the Run button and watch what happens to the entries in the range A1:A10. Hopefully, if all went well, those expressions you typed in should have been converted to their evaluated values. Rick "Shannon" wrote in message ... Thank you very much, I have teach myself macros first, LOL. Hopefully this weekend. Thanks again, Shannon "Rick Rothstein (MVP - VB)" wrote: Can you use a macro? If so, you can have your macro call this subroutine... Sub Solve(R As Range) Dim C As Range For Each C In R C.Value = Application.Evaluate(Replace(LCase$(C.Value), "x", "*")) Next End Sub Simply have your macro pass in the range of cells you want to convert from fractional calculations to numerical values. Something like this... Sub TestMacro() Solve Range("D10:D12") End Sub Note, as long as you use either "x", "X" or "*" for multiplication, "/" for division, "+" for addition and "-" for subtraction, coupled with lots of other functions (such as Sin, Sqrt, etc.) and parentheses, you can do quite complicated calculations with it. Rick "Shannon" <Shannon @discussions.microsoft.com wrote in message ... Does anyone kow if you can convert the following fraction to a decimal automatically. 7/8 x 2 1/4? Thanks in advance, I will score big brownie points with the boss if we can figure this one out :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I have excel convert fractions to decimals? | Excel Worksheet Functions | |||
fractions and decimals! | Excel Worksheet Functions | |||
converting decimals to fractions | Excel Discussion (Misc queries) | |||
converting decimals to fractions | Excel Discussion (Misc queries) | |||
converting decimals to fractions | Excel Discussion (Misc queries) |