Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,311
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 53
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default 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
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
How do I have excel convert fractions to decimals? pgail Excel Worksheet Functions 15 April 3rd 23 03:45 PM
fractions and decimals! AmyTaylor Excel Worksheet Functions 4 April 6th 06 12:20 AM
converting decimals to fractions jason2444 Excel Discussion (Misc queries) 1 January 21st 06 12:07 AM
converting decimals to fractions jason2444 Excel Discussion (Misc queries) 5 January 20th 06 04:38 AM
converting decimals to fractions jason2444 Excel Discussion (Misc queries) 1 January 20th 06 02:58 AM


All times are GMT +1. The time now is 02:00 PM.

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"