Negative numbers
Hello,
Does anyone know how to create a formula that will allow for a begining balance of $0.00 and then take away $20.00 to give you an ending balance of -$20.00. And then have a begining balance of $-20.00 and take away $20.00 for a total of -40.00 instead of $0.00. I keep getting a zero. |
Negative numbers
One way:
A1: 0 A2: 20 B1: =A1 - A2 ==== -20 B2: =B1 - A2 ==== -40 In article , "Jessie" wrote: Hello, Does anyone know how to create a formula that will allow for a begining balance of $0.00 and then take away $20.00 to give you an ending balance of -$20.00. And then have a begining balance of $-20.00 and take away $20.00 for a total of -40.00 instead of $0.00. I keep getting a zero. |
Negative numbers
What formula are you using?
Are you subtracting or adding the $20? "Jessie" wrote: Hello, Does anyone know how to create a formula that will allow for a begining balance of $0.00 and then take away $20.00 to give you an ending balance of -$20.00. And then have a begining balance of $-20.00 and take away $20.00 for a total of -40.00 instead of $0.00. I keep getting a zero. |
Negative numbers
Hi Jessie;
In VBA you can dim the value as an Interger or a Long, do the math in memory and then write it to a cell. An example might be Sub try() MyValue = Int(activecell) - 20 activecell = MyValue End Sub Thanks Greg -----Original Message----- Hello, Does anyone know how to create a formula that will allow for a begining balance of $0.00 and then take away $20.00 to give you an ending balance of -$20.00. And then have a begining balance of $-20.00 and take away $20.00 for a total of -40.00 instead of $0.00. I keep getting a zero. . |
Negative numbers
Hi Greg,
Since Jessie is clearly dealing with currency calculations, it would not seem appropriate to dim your variable as either long or integer. Further, why would you advocate using the Int function? --- Regards, Norman "GJones" wrote in message ... Hi Jessie; In VBA you can dim the value as an Interger or a Long, do the math in memory and then write it to a cell. An example might be Sub try() MyValue = Int(activecell) - 20 activecell = MyValue End Sub Thanks Greg -----Original Message----- Hello, Does anyone know how to create a formula that will allow for a begining balance of $0.00 and then take away $20.00 to give you an ending balance of -$20.00. And then have a begining balance of $-20.00 and take away $20.00 for a total of -40.00 instead of $0.00. I keep getting a zero. . |
Negative numbers
Actually, for a completely different reason, Long might well be a good
way to go. Longs will avoid many of the problems introduced by small rounding errors in IEEE double precision floating point math. Values can be internally multiplied and divided by 100 to match the currency requirements. So try() could be rewritten: Public Sub try() Dim MyValue As Long With ActiveCell MyValue = .Value * 100& - 2000& .Value = MyValue \ 100& End With End Sub However, I don't think that was the original responder's intention. In article , "Norman Jones" wrote: Since Jessie is clearly dealing with currency calculations, it would not seem appropriate to dim your variable as either long or integer. Further, why would you advocate using the Int function? |
Negative numbers
Hi JE,
Longs will avoid many of the problems introduced by small rounding errors in IEEE double precision floating point math. Values can be internally multiplied and divided by 100 to match the currency requirements. Excellent and well-made point! --- Regards, Norman |
Negative numbers
Personal preference is to use the "Currency" data type to help avoid the
small rounding issues. Depending of course on what one is doing... Dana DeLouis "JE McGimpsey" wrote in message ... Actually, for a completely different reason, Long might well be a good way to go. Longs will avoid many of the problems introduced by small rounding errors in IEEE double precision floating point math. Values can be internally multiplied and divided by 100 to match the currency requirements. So try() could be rewritten: Public Sub try() Dim MyValue As Long With ActiveCell MyValue = .Value * 100& - 2000& .Value = MyValue \ 100& End With End Sub However, I don't think that was the original responder's intention. In article , "Norman Jones" wrote: Since Jessie is clearly dealing with currency calculations, it would not seem appropriate to dim your variable as either long or integer. Further, why would you advocate using the Int function? |
All times are GMT +1. The time now is 12:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com