Signature (Visual Basic / VBA)
Public Function GrossProfitCalc( _
Optional ByVal vGrossProfit As Variant _
, Optional ByVal vUnitsSold As Variant _
, Optional ByVal vProductionCost As Variant _
, Optional ByVal vSalePrice As Variant _
) As Variant
Code Examples
GrossProfitCalc(Null, 125, 34, 50) = 2000
GrossProfitCalc(2000, Null, 34, 50) = 125
GrossProfitCalc(2000, 125, Null, 50) = 34
GrossProfitCalc(2000, 125, 34, Null) = 50
GrossProfitCalc(2000, 125, 34, 50) = True ' #5
GrossProfitCalc(2000, 125, 34, 49) = False ' #6
IsNull(GrossProfitCalc(Null, 125, Null, 50)) = True ' #7
GrossProfit = UnitsSold * (SalePrice - ProductionCost)
Parameters
| Parameter | Description |
|---|---|
| vGrossProfit | Gross Profit amount as measured in currency (dollars in the US). |
| vUnitsSold | Number of units sold (a dimensionless measurement). |
| vProductionCost | The cost to produce each Unit as measured in currency. |
| vSalePrice | The selling price of each Unit as measured in currency. |
Notes & Version History
| Summary | This function solves for the argument which is missing or Null or cannot be fixed up to a number. If all arguments are numeric, then this function will return True if the arguments are consistent with the definition of Gross Profit as in example #5, and it will return False if they are not as in example #6. Function will return Null if two or more of the arguments are missing or Null or cannot be fixed up to a number as in example #7. |
| Note | Function will generate an error if there are exactly two arguments that are Object pointers, Errors, or Arrays. Otherwise, it handles that situation gracefully by returning Null. |