#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Calculation

Here's my problem. I have a spreadsheet. There are some Named Ranges.
They are LoanAmount, PurchasePrice, AppraisedValue, and LTV.
I have a button on the sheet that calculates the LTV.
The code says:
Dim LoanAmount As Single, PurchasePrice As Single, etc
LoanAmount = Range("LoanAmount").Value etc
Range("LTV").Value = LoanAmount / AppraisedValue
I have a cell with the formula
=IF(LTV<"",IF(LTV80%,"PMI Needed","PMI NOT needed"))
However, when LoanAmount = 80,000 and AppraisedValue = 100,000
the value that appears in Range LTV is 80.000% (as formatted)
but I see "PMI Needed" because the real value of the calculation
is 80.0000011920928% which appears in the formula bar.
Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Calculation

Try rounding your calculation to a set number of dec places, either as you
calculate, or the final result, or even in the worksheet formula

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Pierce" wrote in message
om...
Here's my problem. I have a spreadsheet. There are some Named Ranges.
They are LoanAmount, PurchasePrice, AppraisedValue, and LTV.
I have a button on the sheet that calculates the LTV.
The code says:
Dim LoanAmount As Single, PurchasePrice As Single, etc
LoanAmount = Range("LoanAmount").Value etc
Range("LTV").Value = LoanAmount / AppraisedValue
I have a cell with the formula
=IF(LTV<"",IF(LTV80%,"PMI Needed","PMI NOT needed"))
However, when LoanAmount = 80,000 and AppraisedValue = 100,000
the value that appears in Range LTV is 80.000% (as formatted)
but I see "PMI Needed" because the real value of the calculation
is 80.0000011920928% which appears in the formula bar.
Any ideas?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Calculation

Try using double instead of single.

But floating point arithmetic (which is what is being used) always has the
difficulty that decimal numbers do not translate exactly so you get
precision problems: I would recommend using a tolerance for your 80% ie use
80.0001



Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm
"John Pierce" wrote in message
om...
Here's my problem. I have a spreadsheet. There are some Named Ranges.
They are LoanAmount, PurchasePrice, AppraisedValue, and LTV.
I have a button on the sheet that calculates the LTV.
The code says:
Dim LoanAmount As Single, PurchasePrice As Single, etc
LoanAmount = Range("LoanAmount").Value etc
Range("LTV").Value = LoanAmount / AppraisedValue
I have a cell with the formula
=IF(LTV<"",IF(LTV80%,"PMI Needed","PMI NOT needed"))
However, when LoanAmount = 80,000 and AppraisedValue = 100,000
the value that appears in Range LTV is 80.000% (as formatted)
but I see "PMI Needed" because the real value of the calculation
is 80.0000011920928% which appears in the formula bar.
Any ideas?



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
Multi threaded calculation (multi CPU) - impact on calculation spe Pascal[_2_] Excel Discussion (Misc queries) 1 December 3rd 08 10:46 AM
age calculation Teapot Excel Discussion (Misc queries) 2 June 3rd 05 10:53 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 10:11 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 09:36 PM
range.calculation with UDF not working when calculation is set to automatic Brian Murphy Excel Programming 5 October 14th 03 07:02 PM


All times are GMT +1. The time now is 07:10 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"