My IF statement:
=IF(AL23*0.2=AM23,"a","r")
Calculates VAT to 3 decimal places so when its checking with AM23 it is returning a false as I only have VAT to 2 decimal places.
How can I make the IF statement only calculate the AL23*0.2 to 2.dps?
You can round it like this:
=IF(ROUND(AL23*0.2,2)=AM23,"a","r")
Use ROUND, which rounds the first argument to the number of decimal places specified by the second argument
=IF(ROUND(AL23 * 0.2, 2) = AM23, "a", "r")
Consider ROUNDDOWN or ROUNDUP for other rounding behaviour: ROUND will round half-way cases and higher upwards.
(Also, consider not hardcoding the VAT rate in a formula in case it changes in the future.)
The round function should work
round(AL23*0.2,2)
so the full statement should be:
=IF(round(AL23*0.2,2)=AM23,"a","r")
Related
I have been trying to apply some conditional formatting to numbers which are formatted externally as fractions with a mask ???/???. In trying to test whether the fraction has a numerator of 1, I apply the formula = =MOD(1/G62,0)<>0, which divides 1 by the fraction itself, which ought to divide with no remainder if it has a numerator of 1, and return 0. If it returns something else then it has a numerator other than 1.
The rule is satisfied when it should not be. To test what is going on, I deconstruct the formula.
The fraction 1/28 is divided into 1 to give 28 and this is correctly displayed. I then populate another cell using the formula =MOD(H62,1) to 28 and it gives 0, as it should. I do the same thing for 1/14 and the result is 1. In other words the MOD of 14, 1 is 1! When I look at the decimal representation of the 2 fractions( I imagine the fractions are actually the representations of the decimal numbers, which themselves will be binary or hex numbers internally), I see the following.
1/28 0.0357142857142856
1/14 0.0714285714285716
When the decimal for 1/28 is subtracted from the decimal for 1/14, the result is 0.035714285714286.
As 1/28 can probably never be accurately represented in decimal, it looks like some rounding down has taken place. Most probably when MOD is applied to the decimal representation of 1/28 with 1, that decimal representation of 1/14 does not divide equally into 1, and this discrepancy is disclosed by the subtraction above.
I am using excel 2016. Maybe this is no longer a problem.
What I am trying to do is test to see if the lowest numerator of a fractional number is 1. Perhaps there is another way to do this in Excel. If so, let me know.
I am trying to write a rounding if statement. If cell <50 round to the nearest 5, if cell is >50 but <1000 round to the nearest 10, if cell is >1000 round to the nearest 100. Can anybody help me out?
My attempt
=IF((T2<50, ROUND(T2*2,-1)/2),IF(AND(T2>50,T2<1000,ROUND(T2,-1)),ROUND(T2,-2)))
I was able to write a similar statement (If cell >0 but <1000 round to nearest 10, otherwise round to nearest 50)
=IF(AND(S3>0,S3<1000),(ROUND((S3),-1)),(ROUND((S3)*2,-2)/2))
Try this:
=IF(A1<50,MROUND(A1,5), IF(AND(A1>=50,A1<1000),MROUND(A1,10),MROUND(A1, 100)))
The MROUND operator (documentation here) rounds to the nearest multiple, which I think is what you're looking for. You also have some issues with your paren grouping, but excel doesn't make it easy to chain if statements. Your AND statement needs to wrap just just the two evaluations and return MROUND(<cell>, 10) when true.
Did you just get a bit mixed up with the IF syntax?
=IF(T2<50, ROUND(T2*2,-1)/2,IF(AND(T2>50,T2<1000),ROUND(T2,-1),ROUND(T2,-2)))
The general form is
IF (logical test, result if true, result if false)
You also had some unnecessary brackets and didn't close the AND brackets.
I am trying to make a number round up or round down depending on if it's higher or lower than 0.8
If the number in U6 is for example 16.8, I want cell V6 to round UP to 17.
If the number in U15 is 14.33 I want V15 to round DOWN to 14.
If the number to be rounded will always be positive, then try:
=ROUND(U6-0.3,0)
Use simple round formula like below.
=ROUND(U6,0)
Round() formula with 0 decimal place will automatically round up greater than .5 to its upper integer and round down less than .5 to lower integer.
Try below formula.
=INT(U6)+((U6-INT(U6))>=0.8)
Depending on the condition put in (U6-INT(U6))>=0.8 the formula will return TRUE or FALSE which will be coerced into 1 or 0 due to arithmetic operation.
Can MS Excel do rounding but only up to the nearest thousandths place and ignore the rest of the decimals in a formula? I've tried value, fixed, round and none of these do what I need.
Let's say I have 100 square feet of space and I pay $1.00566399 per sq foot, I need the formula to round only up to the 5 and ignore the rest of the numbers because when you speak on longer terms it makes a difference in rate.
So I should be multiplying 100sf by $1.01 = $101.00 and not get 100sf * 1.00566399 = $101.57
=trunc(A1,5)
If you want to round up, maybe something like
=trunc((A1*10000+1)/10000,5)
Use the TRUNC($cellRef or number, Decimal places) function. It reduces the number of decimal places WITHOUT rounding, then do your math.
So for example:
=TRUNC(1.00566399,3)
=A1*ROUNDUP(B1,2)
Where A1 contains the number of square feet and B1 contains the price per square foot in it's original long decimal form.
Probably the title is not very suggestive.
Let me explain you with an example. I have:
12345.6
2345.1
12345.00000001
I want those numbers to be roundup to 12350.
How can I do this?
If possible, I would rather use formulas instead of VBA.
You could also use CEILING which rounds up to an integer or desired multiple of significance
ie
=CEILING(A1,10)
rounds up to a multiple of 10
12340.0001 will become 12350
Use ROUND but with num_digits = -1
=ROUND(A1,-1)
Also applies to ROUNDUP and ROUNDDOWN
From Excel help:
If num_digits is greater than 0 (zero), then number is rounded to the specified number of decimal places.
If num_digits is 0, then number is rounded to the nearest integer.
If num_digits is less than 0, then number is rounded to the left of the decimal point.
EDIT:
To get the numbers to always round up use =ROUNDUP(A1,-1)
You can use the function MROUND(<reference cell>, <round to multiple of digit needed>).
Example:
For a value A1 = 21 round to multiple of 10 it would be written as
=MROUND(A1,10)
for which Result = 20
For a value Z4 = 55.1 round to multiple of 10 it would be written as
=MROUND(Z4,10)
for which Result = 60
the second argument in ROUNDUP, eg =ROUNDUP(12345.6789,3) refers to the negative of the base-10 column with that power of 10, that you want rounded up. eg 1000 = 10^3, so to round up to the next highest 1000, use ,-3)
=ROUNDUP(12345.6789,-4) = 20,000
=ROUNDUP(12345.6789,-3) = 13,000
=ROUNDUP(12345.6789,-2) = 12,400
=ROUNDUP(12345.6789,-1) = 12,350
=ROUNDUP(12345.6789,0) = 12,346
=ROUNDUP(12345.6789,1) = 12,345.7
=ROUNDUP(12345.6789,2) = 12,345.68
=ROUNDUP(12345.6789,3) = 12,345.679
So, to answer your question:
if your value is in A1, use
=ROUNDUP(A1,-1)