Excel how to find values in 1 column exist in the range of values in another (approximate) - excel

How can I search if values in one cell (column A) exist in column B. With an approximate threshhold of +/- .5
For instance:
Cell A2: 100.26
Column B: 100.30
Is there a formula that can search A2 within all of column B for an approximate match +/- .5 to return true/false?

You can use COUNTIFS() for this:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)
This tests values in Column B twice. Once to see if there is a value less then A2+.5 and then again to see if that value is also greater than A2 - .5
If you want this to return True/False, just turn it into an inequality:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)>0
Update with Example
To show this working, put value 10 in cell A2. Then in B1 though B5 put the following list:
1
4
10.2
20
24
Now in C1 (or any cell on the same tab that isn't A2 or in Column B) put the formula from above:
=COUNTIFS(B:B, "<" & A2 + 0.5,B:B, ">" & A2 - 0.5)>0
And it will spit out "True" because the value 10 that is in cell A2 is within +/-5 from a value that exists in Column B.

Add 2 helper columns C and D where C is =B1-0.5 and fill down and D is =B1+0.5 and filled down.
Then =if(and(a2>C2,a2<D2,TRUE,FALSE)

Related

Dragging formulas across - Increment columns by more than 1

I can't seem to find anything similar that's already been asked (they all relate to incrementing row numbers rather than columns)
I'm looking to drag a formula across horizontally and have the columns increment by 2
E.g. B1-A1, D1-C1, F1-E1...
Thanks!
You'll need to have a value in cell A1 and B1 for the following to work.
For my testing I put the number 1 in A1 and B1.
Try this in Cell C1:
=IF(MOD(COUNT($A$1:B1),2)=0,COLUMN(B1),IF(B1<>A1,B1,A1))
Here's what you should see when you drag that formula across:
A B C D E F G H I J K L M N
1 1 2 2 4 4 6 6 8 8 10 10 12 12
And this is what the formula does:
The MOD(COUNT() part of the formula counts the cells to the left of it, and if they are a multiple of 2, the value changes.
I've left the value to change to (the 'new' value) as the COLUMN() number for the cell before, just for example's sake. but you can change this part.
The last IF statement at the end checks if the cell before is equal to the cell before that, (eg. Is CELL C1 equal to CELL B1) and if they are not equal, it will give the cell before as a value (the 'copy' value).

Fill blank cell in Excel with value with same ID

I'm not so advanced in excel I need help if is it possible to do.
I have an excel with this column:
ID - Value1 - Value2
I need to update the value1 (or value2):
- only if are blank AND only if the row has the same ID
I make an example, I have this table:
ID Value1 Value2
A1 1 100
A2 2
A3 3
A4 1 200
A5 2 250
Iwould like to fill all the empty cell in this way
ID Value1 Value2
A1 1 100 200
A2 2 250
A3 3
A4 1 100 200
A5 2 250
Thank you for any help.
Ok, so your data is a mixture of numbers and texts. You can generate two new columns with the desired values using formulas. Choose two new, adjacent columns, say D and E, and enter this CSE formula in row say in cell D2:
D2:
=IFERROR(IF(ISBLANK(B2),INDEX(B$2:B$99,
MATCH(1,($A$2:$A$99=$A2)*(1-ISBLANK(B$2:B$99)),0)),B2), "")
CtrlShiftEnter
Enter the formula in D2 with CtrlShiftEnter and then copy/paste in the cells of columns D and E (or as I said any two adjacent columns).

Logical calculation in Excel

I need advice/help. I am working on calculation in excel where I have data like mentioned below.
. A B C D E F G H
1| A275 A277 A273 A777 A777 TOTAL A222 GRAND TOTAL
2| 5 7 4 3 4 7 7
Now, I want to count row 2 based on the header.
Here is the condition.
If A1 <> B1 then take A1, if B1 <> C1 then take B1, if C1 <> D1 then C1, so on.
But tricky part is...
If D1<>E1 then D1 else (if E1<>F1 then E1 else (if F1 = "TOTAL" then F1 else(if F1<>G1 then F1)))
In short H2 should have 30 and not 37.
Added comments:------------------------------------
So, Basically if A1<>B1 then take A1 but if A1=B1 then take B1, but then for B1, its a same rule like if B1<>C1 then take B1, but if B1=C1 then take C1 and for C1, same rule. Stopping point will be "TOTAL". Along with these logic I need to check if any cell in row 1 is "TOTAL" then take value for same column. Now this "TOTAL" can be in any cell in row 1.
So from above table my calculation will be 5(A2) + 7(B2) + 4(C2) + 7(F2) + 7(G2) = 30
In this calculation I have not included D2 and E2 as D2=E2 so I took D2, here E2<>F2 so I should have taken E2, but as F2="TOTAL" so I took F2 and not D2 and E2.
I hope this make sense. (Sorry, I know its confusing.)
I have data in more then 100 columns.
Can this be achieved using Macro?
------------------------------------------------------------
Another pain point is data and header are dynamic, so I can't have a fix format. Logic should be in a way that can handle the dynamic data and header.
Any help or suggestion will be greatly appreciated.
I achieved the results you want with this.
Add a helper row. In cell A3 write this formula and drag it to the right:
=IF(OR(A$1=B$1,B$1="TOTAL"),0,1)
Calculate sum in say cell H4 (not H2 because if the formula refers to entire row 2 there will be circular reference):
=SUMIF($3:$3,1,$2:$2)

Excel Formula- Divide a sum into multiple cells?

I need a formula for excel that will allow me to take a sum and divide it up into a number of cells.
for example:
A1= sum
B1 to B4 needs to have a portion of the devided sum
i.e. if sum 1000 then B1=100 B2=200 B3=300 B4=400
Thank's in advance guys
The decomposition rule is that it goes from B1 to B4 in intervals of 100...adding to the pervious
The formula for the lowest term is (2 * s / n - (n - 1) * d) / 2 where
s is the sum
n the number of terms
d the common difference
You have n = 4 and d = 100.
So the lowest term is (s / 2 - 300) / 2.
So if cell A1 contains the sum (1000), you can write =0.5*(A1 / 2 - 300) in cell B1
Then B2 = B1 + 100, B3 = B2 + 100 and B4 = B3 + 100.
The formula comes from the sum of an arithmetic progression.
Try this
Set alias to cell A1 as amount
Use a cell for the number of division which is 4, assume to put in cell A2
Calculate the formula for the total portions to divide, put it in cell A3. In your case A3 =A2*(A2+1)/2
Set alias to cell A3 as total
In each of B columns, set the formula as =(ROW()/total*amount)
Copy the formula from step 5 above until the maximum row in B according to your need

Excel function for multiple formula

How can I do this equation in excel
If text "t" then goto cell x if not goto cell y
And perform function
I.e
If cell has letter t do (28.5%*cell) if not do (15%*cell)
So the way i understand, You have 3 columns, 1 with a letter, and 2 with numbers. column 1 is either t or something else, and then column 2 and 3 are various answers. So my solution assumes that the letter is column a, and the numbers are columns b and c, and the function goes in d. you can adjust accordingly if the columns are different. then you can drag the function down (or up if you place it in a cell thats on at the top) and it will adjust the row numbers.
=IF(A1 = "t",B1 * 0.285,C1 * 0.15)
so basically it takes cell A1 and checks if it is the letter t. if so, it takes the number in b1` and multiplies it by 28.5% and if not, it takes the number in c1 and multiplies it by 15%.
If text "t" then goto cell x if not goto cell y
Assuming you meant "resolve to" by goto, this could be what you are looking for:
=IF(S1="t",X1,Y1)
When the value of cell S1 is "t", the value of the cell the formula is in, would be the value of cell X1, Y1 otherwise.
If cell has letter t do (28.5%*cell) if not do (15%*cell)
This would be the formula:
=IF(IFERROR(SEARCH("*t*",A1)), 28.5% * B1, 15% * C1)
Some test-data:
A | B | C
1 mytest | 100 | 200
EDIT a ',' was missed there.. I popped that into Excel and it didn't work.
should be =IF(IFERROR(SEARCH("*t*",A1),), 28.5% * B1, 15% * C1)
and that works

Resources