Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Make it positive

Here's the situation, I have a problem that has 20 units purchased and
I receive a 7% discount for over 20 units purchased. Cost per unit is
$52. Therefore, in the following If statement, the total would be 20
* $52 * .07 = 72.8 then take this total and subtract if from 20 * $52
which should equal $967.2 but I get a negative with my statement. I
think it's easy but I don't see it, please advise...thanks...

Dim foundRowNum As Integer
Dim numberPurchasedStr As String
Dim totalSpent As Currency
Dim unitCostRow As Currency
Dim discountRow As Double

If (CInt(numberPurchasedStr) = Range("C" & foundRowNum).Value) Then
totalSpent = CDbl(numberPurchasedStr) * unitCostRow *
discountRow _
- CDbl(numberPurchasedStr) * unitCostRow

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Make it positive

You formula is backwards. You are subtracting the 1040 from 72.8 rather than
subtracting 72.8 form 1040

Here is the easy fix:

Sub AAA()

Dim numberPurchasedStr As String
Dim totalSpent As Currency
Dim unitCostRow As Currency
Dim discountRow As Double
numberPurchasedStr = "20"
unitCostRow = 52
discountRow = 0.07

totalSpent = -CDbl(numberPurchasedStr) _
* unitCostRow * discountRow _
+ CDbl(numberPurchasedStr) * unitCostRow
Debug.Print CDbl(numberPurchasedStr) _
* unitCostRow * discountRow, _
CDbl(numberPurchasedStr) * unitCostRow, _
totalSpent
End Sub

produces
72.8 1040 967.2

--
Regards,
Tom Ogilvy


" wrote:

Here's the situation, I have a problem that has 20 units purchased and
I receive a 7% discount for over 20 units purchased. Cost per unit is
$52. Therefore, in the following If statement, the total would be 20
* $52 * .07 = 72.8 then take this total and subtract if from 20 * $52
which should equal $967.2 but I get a negative with my statement. I
think it's easy but I don't see it, please advise...thanks...

Dim foundRowNum As Integer
Dim numberPurchasedStr As String
Dim totalSpent As Currency
Dim unitCostRow As Currency
Dim discountRow As Double

If (CInt(numberPurchasedStr) = Range("C" & foundRowNum).Value) Then
totalSpent = CDbl(numberPurchasedStr) * unitCostRow *
discountRow _
- CDbl(numberPurchasedStr) * unitCostRow


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Make it positive

Aye, it was that simple...thanks a bunch...

On May 18, 2:57 pm, Tom Ogilvy
wrote:
You formula is backwards. You are subtracting the 1040 from 72.8 rather than
subtracting 72.8 form 1040

Here is the easy fix:

Sub AAA()

Dim numberPurchasedStr As String
Dim totalSpent As Currency
Dim unitCostRow As Currency
Dim discountRow As Double
numberPurchasedStr = "20"
unitCostRow = 52
discountRow = 0.07

totalSpent = -CDbl(numberPurchasedStr) _
* unitCostRow * discountRow _
+ CDbl(numberPurchasedStr) * unitCostRow
Debug.Print CDbl(numberPurchasedStr) _
* unitCostRow * discountRow, _
CDbl(numberPurchasedStr) * unitCostRow, _
totalSpent
End Sub

produces
72.8 1040 967.2

--
Regards,
Tom Ogilvy

" wrote:
Here's the situation, I have a problem that has 20 units purchased and
I receive a 7% discount for over 20 units purchased. Cost per unit is
$52. Therefore, in the following If statement, the total would be 20
* $52 * .07 = 72.8 then take this total and subtract if from 20 * $52
which should equal $967.2 but I get a negative with my statement. I
think it's easy but I don't see it, please advise...thanks...


Dim foundRowNum As Integer
Dim numberPurchasedStr As String
Dim totalSpent As Currency
Dim unitCostRow As Currency
Dim discountRow As Double


If (CInt(numberPurchasedStr) = Range("C" & foundRowNum).Value) Then
totalSpent = CDbl(numberPurchasedStr) * unitCostRow *
discountRow _
- CDbl(numberPurchasedStr) * unitCostRow



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
Subtracting positive amts from negative and positive from positive bwbmom Excel Worksheet Functions 3 February 12th 10 03:15 PM
make a positive number to negative D Excel Worksheet Functions 3 March 30th 08 10:28 PM
positive value violet Excel Programming 1 December 11th 06 07:09 AM
Easy way to make negative data positive? Sarah Charts and Charting in Excel 2 February 2nd 06 08:37 PM
Formula to make Negative Values Positive & Positive Values Negative? mustard Excel Discussion (Misc queries) 4 September 26th 05 10:05 PM


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