Excel or VBA - VLOOKUP with IF Coniditon - excel

Hi,
I would like to investigate a huge list that I can distinguish the Acc numbers according to the mail adresses. The things that I
would like to do if email adresses has a seperate Acc and if they
equal each other( I mean if Acc numbers are equal),write a "equal" if
the criterias were not equal with the same email then write a
"multiple criteria"..
Is there any way to do that with Excel formulas or VBA ?
Mail Acc
uralsmh#gmail.com C1234
uralsmh#gmail.com C2345

Part 1 - check for duplicates
Create a helper column that sticks columns A and B together and then count this column. You can use the & character for this:
A B C D
1 abc 123 =A1&B1 =COUNTIF($C$1:$C$1000,C1)
2 abc 123 =A2&C2 =COUNTIF($C$1:$C$1000,C2)
3 def 123 =A3&C3 =COUNTIF($C$1:$C$1000,C3)
If you get a number greater than 1 in column D, then that row is a duplicate of another row.
Part 2 - find multiple accounts
Now you have found the exact duplicates, any email addresses that match must have different account numbers. So, in column E, just count column A:
A B C D E
1 abc 123 =A1&B1 =COUNTIF($C$1:$C$1000,C1) =COUNTIF($A$1:$A$1000,A1)
2 abc 123 =A2&C2 =COUNTIF($C$1:$C$1000,C2) =COUNTIF($A$1:$A$1000,A2)
3 def 123 =A3&C3 =COUNTIF($C$1:$C$1000,C3) =COUNTIF($A$1:$A$1000,A3)
If you get a number greater than 1 in column E and you had a 1 in column D, you have found an email address with multiple accounts.

Related

how to count distinct values in excel for a matrix form

I have looked if this has been asked, but could not find out exactly.
I' ve been trying to count distinct values.
I tried sumproduct,sum(1/countif) etc, so far I got nothing but a div error or 0.
Basically, I' ve two columns: Campaign_no and customer_id.
what I need is count unique customers for each campaigns and count unique customers that appears in the campaigns at the same time, sort of matrix.
The table is as follows:
Campaign_no
Cust_id
A
1
A
2
A
2
B
1
B
4
B
5
B
9
C
4
C
5
C
6
C
7
What I need is below:
Campaigns
A
B
C
A
2
1
0
B
1
4
2
C
0
2
4
As you see Campaign A has 2 unique customers, so A-A cell is 2.
Campaign A and B have one customer in common, so A-B cell is 1.
Campaign A and C have no common customer, this box got 0.
Campaign B and C has 4 unique customer on their own,
but they have two common customers, so B-C box has 2 ( if those customers were the same, it would have been 1) .
Is there way of calculating this without vba or PT? I'm using Excel 2017.
Much appreciated.
Here is a solution using helper cells.
C2 is =A2&B2. Copy it to C3:C12.
D2 is =IF(ISNA(MATCH(B2,D1:$D$1,0)),B2,""). Copy it to D3:D12.
E2 is =IF($D2="","",1-ISNA(MATCH(E$1&$D2,$C$2:$C$12,0))). Copy it to E2:G12.
E15 is =SUMIFS($E$2:$E$12,E2:E12,1). Copy it to F15:G15.
E16 is =SUMIFS($F$2:$F$12,E2:E12,1). Copy it to F16:G16.
E17 is =SUMIFS($G$2:$G$12,E2:E12,1). Copy it to F17:G17.
You may be able to get away without using the helper column C in Office 2017. I only have Office 365, so I couldn't it correctly.
Here's one that you could try, but it assumes that the data is sorted into contiguous blocks in alphabetical order of campaign exactly as shown in the sample data:
=SUMPRODUCT((COUNTIFS($A$2:$A$12,F$1,$B$2:$B$12,INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,0)):INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,1)))>0)
/COUNTIFS($A$2:$A$12,$E2,$B$2:$B$12,INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,0)):INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,1))))
The idea is that you use countifs to check through each customer ID in campaign A (for example) to see if it's present in campaign B. But it's possible that a customer ID appears more than once in campaign A, so you still have to divide by the count of each customer number in campaign A to get the unique count.

EXCEL Sum up points based on placements (combine VLOOKUP and SUM)

e.g. I have a list of race results:
A B C D E F...
NAME P. RACE1 RACE2 RACE
abc =? 1 3 3
bcd 3 2 4
cde 4 4 2
def 2 1 1
and another sheet with points for each result:
A B
PLACE POINT
1 10
2 5
3 2
4 1
Is it possible to get the total points in sheet1 column B based on the race results in column C-E..?
Is it a connection from VLOOKUP and SUM?
Yes, that's possible. You can use a SUMPRODUCT formula for that. You may use this one in column B:
=SUMPRODUCT((C2:E2=$A$13:$A$16)*$B$13:$B$16)
Your result will look like this:
This is an array function. The term C2:E2=$A$13:$A$16 will check for race 1 to 3 if it was 1st, 2nd, 3rd or 4th place. This will result in an "imaginary" array of TRUE and FALSE. For name "abc", it will look like that.
Those results are then multiplied with the points from B13:B16 and the sum is formed.
In Excel O365, one could use:
Formula in B2:
=SUM(VLOOKUP(C2:E2,H$2:I$5,2))

Sum values if multiple conditions met in different sheet

I have one sheet that creates a mapping of names to values (Map_Sheet). In another sheet there are values for each name in the mapping table (Data_Sheet). What I am trying to do is add values based on certain conditions in the mapping table. For example: I want to add all counts of dog by bread and color. So in the mapping table I would look for all dogs that are brown and of a certain bread and get their names and manually add them together. I want to have a formula that does the addition based upon multiple conditions from Map_Sheet.
Here is an example of the data:
Map_Sheet-
name|bread|color|age
a x b 2
b y w 3
c x b 2
d z f 4
Data_Sheet -
id|a|b|c|d
0 3 4 2 1
1 1 2 4 2
2 3 5 7 2
3 1 2 6 9
4 1 3 5 7
And for each ID in the data sheet I want a count of bread X with color B. So I would add for ID0 values for A and C, (3+2) - so ID0 = 5, etc for each id.
I cannot use VBA so I was looking into using INDEX and MATCH but I cannot wrap my head around it. Any ideas? Thanks!
If the row headers in the first sheet match the column headers in the second sheet, you can put this formula in (say) G2 of the second sheet.
=SUM(TRANSPOSE(Map!$C$2:$C$5="b")*C2:F2)
If the column headers in the second sheet were in a different order, you would have to use something like:-
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF(Map!$C$2:$C$5="b",Map!$A$2:$A$5),0))))
Both of these are array formulae. You can add extra conditions to select breed as well as colour using the same basic pattern:-
=SUM(TRANSPOSE((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"))*C2:F2)
or
=SUM(C2:F2*NOT(ISERROR(MATCH($C$1:$F$1,IF((Map!$C$2:$C$5="b")*(Map!$B$2:$B$5="x"),Map!$A$2:$A$5),0))))

Excel, IF and COUNT duplicates

So here it is,
Column A has duplicate and unique number values, Column B has duplicate and unique Strings (Names). I need to count the instances of unique number values in A matched to their name in B.
So it would be like =COUNTIF(B1:B100,"XYZ") "Then counts all unique number values in A1:A100 that "match" or have XYZ in column B.
Col A - Col B
ABC - 963
ABC - 963
FFF - 367
FFF - 367
FFF - 234
XYZ - 678
XYZ - 221
XYZ - 334
What I need:
ABC = 1 ( one unique instance where Col A and Col B (ABC,963) )
XYZ = 3 ( three unique instances (XYZ,678 : XYZ,221 : XYZ,334
FFF = 2 ( two unique instances ( FFF,367 and FFF, 234 )
So I need to sum up all the unique instances of Column A that only match the strings in column B.
Thanks in advance !, I'll keep searching in the meantime !
I believe that you are looking to retrieve a count of the unique combinations of number and name. Perhaps something like the following.
        
The formula in E2 is,
=SUMPRODUCT((A$2:A$99<>"")/COUNTIFS(B$2:B$99, B$2:B$99&"", A$2:A$99, A$2:A$99&""))
The formula in E4 is,
=SUMPRODUCT((A$2:A$99=D4)/COUNTIFS(B$2:B$99, B$2:B$99&"", A$2:A$99, A$2:A$99&""))
Fill E4 down as necessary.

Vlookup doesn't work with column of string

I have 4 columns, containing 2 columns of names and 2 columns of values, as below. I need to update Column B with value in K, if the name1 = name2. Both name columns are formatted as text, and values columns are formatted as numeric.
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A A 123
B B 456
C X 000
D Y 000
E Z 000
F C 789
I insterted the following vlookup in the first row of column B, but it returns the name in column A.
=VLOOKUP(A4,J2:J22890,K2:K22890)
I'm expecting to have the following result:
(A) Name1 (B) Value1 (J) Name2 (K) Value2
A 123 A 123
B 456 X 000
C 789 B 456
D Y 000
E Z 000
F C 789
Am I using vlookup a the wrong way? or is it due to the fact that I'm looking up strings??
I think it should be
=VLOOKUP(A4,J2:K22890,2,0)
1.First parameter is the value you are looking for,
2.second one is the range (it can be multiple columns, with the referenced data in the most-left column of the selection),
3.followed by the column's number where the records should be retrieved from,
4.and lastly a flag (1 or 0) if you would like to accept similar results (1) or exact matches only (0)
Since I can't edit the post because it's not enough characters and I can't comment because I don't have enough rep...
=VLOOKUP(A4,$J$2:$K$22890,2,0)
This is Alex's post with absolute references for the lookup table array.

Resources