I have a list of results that may return a decimal value between 0 and 5. For business purposes I need to force Excel to replace the number as follows:
Any decimal value between 0 and 1 needs to show as the whole number 0
Any decimal value between 1 and 2 needs to show as the whole number 1
Any decimal value between 2 and 3 needs to show as the whole number 2
Any decimal value between 3 and 4 needs to show as the whole number 3
Any decimal value between 4 and 4.5needs to show as the whole number 4
Any decimal value between 4.5 and 5 needs to show the actual decimal value.
So, if the decimal value is 1.5, I want Excel to show it in the cell as 1. Or, if the decimal value is 4.5, I want excel to show it as 4.5.
I've tried using the following nested IF function (in this example the number to replaces is in cell L28):
=IF(L28>=4.5,L28,IF(L28<4.5>=4,"4",IF(L28=4,"4",IF(L28<4>=3,"3",IF(L28<2>=1,"2",IF(L28<1>=0,"0"))))))
However for some reason it works on values 4 or greater, but for anything <4 still shows 4, and I can't figure out why.
Should I be doing this in VBA instead?
Thanks in advance, and I'm hoping I explained this clearly...
This is why the FLOOR() function exists.
=IF(A1<=4.5,FLOOR(A1, 1),A1)
Related
One of my Excel column of my board have to store numbers of 9 digits.
I'm looking for a solution to keep only the 9 last digits of any bigger number past in this specific column. It's only entire number.
Also if after formatting the number it appear that the number starts with 0 the 0 have to be kept. Is there another solution than adding an '0 at first ?
Here is what I already done : (i is the row number / Range01 is Range("A14:O400"))
If Len(Range01.Cells(i,5).value) = 9 Then
Range01.Cells(i,5).Interior.color = vbGreen
ElseIf Len(Range01.Cells(i,5).value) = 8 Then
Range01.Cells(i,5).value = "'0" & Range01.Cells(i,5).value
ElseIf Len(Range01.Cells(i,5).value) > 9 Then
????
Else
Range01.Cells(i,5).Interior.color = vbRed
End If
Thanks for the help.
The simplest way to get the last nine numbers of an integer is:
=MOD(A1,1000000000)
(For your information, that's one billion, a one with nine zeroes.)
If you're interested in showing a number with leading zeroes, you can alter the cell formatting as follows: (the format simply contains nine zeroes)
If you're interested in keeping the zeroes, you might need to use your number as a string, and precede it with a good number of repeated zeroes, something like:
=REPT("0",9-LEN(F8))&F8
Take the length of your number (which gets automatically converted into a string)
Subtract that from 9 (so you know how many zeroes you need)
Create a string, consisting of that number of zeroes
Add your number behind it, using basic concatenation.
You can simply use the math operator of modulus. If you want the last 9 digit you can write:
n % 10000000000
Where n is the number in the column.
In VBA:
MOD(n,1000000000)
Somewhat simple problem:
I need to turn a column A, which contains numbers with up to 1 decimal (20, 142, 2.5, etc.) to a string with a specific format, namely 8 whole digits and 6 decimal digits but without the actual decimal period, like so:
1 = 00000001000000
13 = 00000013000000
125 = 00000125000000
46.5 = 00000046500000
For what it's worth, the input data from column A will never be more than 3 total digits (0.5 to 999) and the decimal will always be either none or .5.
I also need for Excel to leave the zeroes alone instead of auto-formatting as a number and removing the ones at the beginning of the string.
As a makeshift solution, I've been using =CONCATENATE("'",TEXT(A1,"00000000.000000")), then copying the returning value and "pasting as value" where I actually need it.
It works fine, but I was wondering if there was a more direct solution where I don't have to manually intervene.
Thanks in advance!
=TEXT(A1*1000000,"0000000000000") I think that's what you mean.
OBJECTID E201701 G201701 E201702 G201702 E201703 G201703 E201704 G201704
1 2 5 6 5 -1 NaN 6 5
I want to find if a particular entry (i.e. objectid) has negative value in any of variable (e201701, etc). I tried;
IF(AND(B2>0,C2>0,D2>0,E2>0,F2>0,G2>0,H2>0),1,0)
but it just give me 1 irrespective.
Your formula is asking "Is thisCell > (Greater than) thisCell?" Try using this. Also, change the AND to an OR because AND is going to check all values and if ALL of them are returning true then it will return as such. OR will check EACH individually.
IF(OR(B2<0,C2<0,D2<0,E2<0,F2<0,G2<0,H2<0),1,0)
Which is asking "Is thisCell > (Less than) thisCell?"
If you use excel 2013 or later then you can use below formula. This formula will also give you position number where the negative value is. As your sample data it will return 6 because negative value is in 6th position.
=AGGREGATE(15,6,COLUMN(A1:I1)/(A1:I1<0),1)
For sample same results as #xTwisteDx but shorter and easy to extend (eg to include G201704 just change H to I) :
=1*(MIN(B2:H2)<0)
I have 4 different values being generated on a spreadsheet in different cells:
A=88.45%
B=88.45%
C=1.69%
D=95.67%
I need to add these values up and divide it by 4 to get the difference from a possibility of 100%. So, the functions I've written are:
A= =SUM(1-(D6/C6))
B= =SUM(1-(F6/C6))
C= =SUM(I6/H6)
D= =SUM(1-(K6/C6))
However, if I just have a formula that adds those cells up while they are displaying as a % and then divide it by 4 it doesn't give me the intended number which I need. The only way I've figured out to give me the accurate result was to convert them into decimals, but I'm not sure how to exactly write that. If it's even possible. I still need them displaying as a % in the original cells is the issue.
A= 0.1155
B= 0.1155
C= 0.0169
D= 0.0433
Divide those by 4 and you get the correct 7.28%. Then I need to subtract that from 100% to generate the actual average of those 4 cells.
Any insight?
**EDIT* 2nd formula added
The proper formula to obtain your desired result of 7.28% from the four values in Row 34 (January) is:
=SUM(1-E34,1-G34,J34,1-L34)/4
OR
=1-AVERAGE(E34,G34,1-J34,L34)
where:
E34:= 88.45%
G34:= 88.45%
J34:= 1.69%
L34:= 95.67%
As an aside, the SUM function in each of those cells is entirely superfluous.
=1-D34/C34
will give the same result as
=SUM(1-(D34/C34))
After scraping a website I ended up with values with dashes in the data like 7-6, 12-5, 3-12. I was able to separate the data into to their own columns making the previous examples being 7, 6 , 12,5 3,12, but the data has turned from values that you can add and subtract to something like a string. Is there a way to make the strings into values.
0 15
1 2
5 6
4 8
3 2
2 1
If i go through each cell and double click the strings it converts to values, but I cant do that to 55000 cells.
you can convert a text string that represents a number to number format using the Value() formula
Example:
B1 = Value(A1))
if A1 = 15 in text format
You can select the whole columns and convert to number. Go to menu Data > Convert and then, follow the wizard.