TheDude111
New Member
- Joined
- Feb 7, 2011
- Messages
- 25
hey guys
Im using excel 2011,
basically what Im doing is taking a product quantity and dividing it among customer based on a percentage.
e.g. divide 10 apples between 2 customers A and B with A getting 70% and B getting 30 % etc.
However some products will only get sold in groups of 4,6,8 etc.
In my formula this is what is in column AP
I was using application.round which works for the majority of cases in my formula.
Code:
There are cases however when i end up with a ".5" for each and both are rounded up. Which leaves me with more than the original figure.
I tried using a rounding function
Code:
Any help or ideas would be appreciated.</td></tr></tbody></table>
Im using excel 2011,
basically what Im doing is taking a product quantity and dividing it among customer based on a percentage.
e.g. divide 10 apples between 2 customers A and B with A getting 70% and B getting 30 % etc.
However some products will only get sold in groups of 4,6,8 etc.
In my formula this is what is in column AP
I was using application.round which works for the majority of cases in my formula.
Code:
Code:
<style>.alt2 font { font: 11px monospace ! important; color: rgb(51, 51, 51) ! important; }</style>
[FONT=Arial][SIZE=2][COLOR=#000000]While (Range("A" & loopCounter4) <> "")
If (Range("E" & loopCounter4) = "A") And (Range("G" & loopCounter4) = "1") Then
Range("AC" & loopCounter4) = Application.Round(((Range("AB" & loopCounter4) / Range("AP" & loopCounter4))) * 0.3, 0) * Range("AP" & loopCounter4)
ElseIf (Range("E" & loopCounter4) = "B") And (Range("G" & loopCounter4) = "1") Then
Range("AC" & loopCounter4) = Application.Round(((Range("AB" & loopCounter4) / Range("AP" & loopCounter4))) * 0.7, 0) * Range("AP" & loopCounter4)[/COLOR][/SIZE][/FONT]
There are cases however when i end up with a ".5" for each and both are rounded up. Which leaves me with more than the original figure.
I tried using a rounding function
Code:
Code:
<table class="tborder" id="post2570431" align="center" border="0" cellpadding="6" cellspacing="0" width="100%"><tbody><tr><td class="alt1" id="td_post_2570431"><style>.alt2 font { font: 11px monospace ! important; color: rgb(51, 51, 51) ! important; }</style>
[FONT=Arial][SIZE=2][COLOR=#000000]Function RoundSpecial(pValue As Double) As Double
Dim LWhole As Long
Dim LFraction As Double
'Retrieve the interger
LWhole = Int(pValue)
'Retrieve the fraction
LFraction = pValue - LWhole
If LFraction < 0.5 Then
CustomRound = LWhole
Else
CustomRound = LWhole + 0.5
End If
End Function[/COLOR][/SIZE][/FONT]
Any help or ideas would be appreciated.</td></tr></tbody></table>