Excel VBA to find non unique values with multiple conditions - excel

I am looking for some help trying to create an excel macro. I have a very large sheet that look a bit like this:
Account NAME Address Dealer
68687 Sara 11 Wood 1111
68687 Sara 11 Wood 1111
68687 Sara 11 Wood 1111
12345 Tom 10 Main 7878
12345 Tom 10 Main 7878
54321 Tom 10 Main 7878
10101 John 25 Lake 3232
10101 25 Lake 3232
11111 John 25 Lake 3232
What I need to do is to highlight all the rows on the sheet where each Dealer has more than one unique value in the Account column, but it must also have some value in the name column.
So in the above example I would only want to highlight all the rows for dealer 7878.
I am not certain if I should look at loops or arrays, they might take a long time as the sheet is quite large.
Looking for some help.
Thanks.

James - Dirk gave you a good answer in his comment. It looks like this ...
The format formula is also put into Column F, so you can see the results of the calculation.
If you feel you should still have a VBA solution, this gives you a good starting point for how to layout your code ...
Ignore rows with empty name
Count rows where the dealer is the same as the dealer in the current row, and the account is NOT the same as the account in the current row
If the count found in Step 2 is greater than 0, highlight the current row.

Related

Google sheets formula to get the Top 5 List With Duplicates

I'm trying to compile a best 5 and worst 5 list. I have two rows, column B with the number score and column C with the name. I only want the list to include the name.
In my previous attempts the formula would get the top/bottom 5 but as soon as a duplicate score appeared the first known name with that value would just repeat.
Here is my data
26 Cal
55 John
55 Mike
100 Steve
26 Thomas
100 Jaden
100 Jack
95 Josh
87 Cole
75 Brett
I've managed to get the bottom 5 list formula correct. This formula works perfectly and includes all names of duplicate scores.
Example of what I get:
Cal
Thomas
John
Mike
Brett
=INDEX($C$56:$E$70,SMALL(IF($B$56:$B$70=SMALL($B$56:$B$70,ROWS(E$2:E2)),ROW($B$56:$B$70)-ROW($B$56)+1),SUM(IF($B$56:$B$70=SMALL($B$56:$B$70,
ROWS(E$2:E2)),1,0))-SUM(IF($B$56:$B$70<=SMALL($B$56:$B$70,ROWS(E$2:E2)),1,0))+ROWS(E$2:E2)))
Here is the formula I've tried to get the top 5 - however I keep getting an error.
=INDEX($C$56:$E$70,LARGE(IF($B$56:$B$70=LARGE($B$56:$B$70,ROWS(E$2:E2)),ROW($B$56:$B$70)-ROW($B$56)+1),SUM(IF($B$56:$B$70=LARGE($B$56:$B$70,
ROWS(E$2:E2)),1,0))-SUM(IF($B$56:$B$70<=LARGE($B$56:$B$70,ROWS(E$2:E2)),1,0))+ROWS(E$2:E2)))
Example of what I'm looking for
Steve
Jaden
Jack
Josh
Cole
You can set two queries like this for both cases:
=QUERY(B56:C70,"Select C order by B desc limit 5")
=QUERY(B56:C70,"Select C order by B limit 5")
Use SORTN() function like-
=SORTN(A1:B10,5,,1,1)
To keep only one column, wrap the SORTN() function with INDEX() and specify column number. Try-
=INDEX(SORTN(A1:B10,5,,1,1),,2)

Updating spreadsheet after altering the original one

I have the following data in spreadsheet A.
name trait1 trait2 nice
0 Adam 29 81 0
1 Barry 17 75 1
2 Chris 62 0 1
I wish to create a spreadsheet B that will be a filtered copy of this data. Namely, let's assume for a moment that I want to filter nice = 1 and am interested only in column name. The copy in spreadsheet B would be as shown below. In spreadsheet B I wish to be adding some extra columns, e.g. education.
name nice education
1 Barry 1 primary
2 Chris 1 university
What I want to achieve is a spreadsheet B that will get updated if anything changes in spreadsheet A. So for example, if I were to change the name Barry to Ben. The spreadsheet B would become the following.
name nice education
1 Ben 1 primary
2 Chris 1 university
Similarly (and what I find to be the hardest), if a row is added in spreadsheet A, e.g.
name trait1 trait2 nice
0 Adam 29 81 0
1 Barry 17 75 1
2 Matt 69 11 1
3 Chris 62 0 1
The updated spreadsheet B would be as follows:
name nice education
1 Barry 1 primary
2 Matt 1
3 Chris 1 university
So I want the education column to remain the same.
My approach of using a combination of =IF() and =VLOOKUP() functions ultimately did not work. Guess I am really curious about how to connect rows of education to names. So that when a row is added in spreadsheet A, then spreadsheet B gets updated but the education field connected to the new row is empty and will be filled by hand later on.
Since you are looking for a finished product to be in Google Sheets, I'd advise to use QUERY():
Formula in I1:
=QUERY(INDEX({A:D,VLOOKUP(A:A,F:G,2,0)}),"Select Col1,Col4,Col5 where Col4=1")
Note: I made the assumption you pull the education in through a VLOOKUP() (since you mentioned that in the body of the question).

How to find the sum for customer's multiple payments using Excel formula?

Hello,
I am trying to configure a =if(countif) code in Excel to calculate the sum for customers of multiple payments. I'm basing their unique value on their Customer# as that's the most unique identifier as some people might have the same name. The code I've entered is having some issues and I don't have a strong experience with using this type of formula. Below is a generic sample and the code.
A:Name B:Customer# C:Paid D: Sum
Jane Doe 1044 88
Jane Doe 1044 22
Jack Doe 1088 6
Jack Doe 1088 5
Jane Doe 1520 200
Katey Doe 1222 65
Katey Doe 1222 4
Jack Doe 1045 6
Jack Doe 1045 78
Bill Doe 1011 5
(I'm unable to post an image yet)
This is the code I'm trying to use in column D:
=IF(COUNTIF(B:B,B1)>1,IF(COUNTIF(B$:B1,B1)=1,=SUM(C:C,C1),=SUM(C:C,C1))"")
SUMIF
On cell D2 enter the formula =SUMIF($B$2:$B$11,B2,$C$2:$C$11) and drag down which will create this table
Pivot Table
A pivot table would be my summary method. This will stop you from having repeated values. Notice that the Sum for each customer is repeated which is not the ideal view. Instead you can try a simple pivot that only requires 3 columns: Name, CSR #, & Paid
Seems like you want to use SUMIF()
Formula in D2:
=SUMIF($B$2:$B$11,B2,$C$2:$C$11)
Drag down..

Excel multi value counter

I couldn't find anything similar.
I have a pretty big excel table but I can't get what I need from it.
I have a column for example of names
John
Johnny
Arny
Arny
John
Johanatan
Jeremie
Brook
Arny
Johanatan
I want it to return or show me results like that
Johnny 1
Arny 3
John 1
Jeremie 1
Brook 1
Johanatan 2
Couldn't find an appropriate excel to result me with that.

How to accumulate text cells

Is it possible in Excel 2010 to have a function that finds duplicates in a column range and based on the number of duplicates, then accumulates the equal range into one cell?
This is how my data looks:
Family Name Age Postcode
Doe John 40 1400
Doe Jane 35 1400
Doe Baby 5 1400
Mark Peter 14 1600
Matt Simon 25 1700
Matt Paul 14 1700
And I would like the output to look like this:
Family Name [Member/age] [Postcode]
Doe John [John/40, Jane/35, Baby/5] 1400
Mark Peter[Peter/14] 1600
Matt Simon[Simon/25, Paul/14] 1700
It looks like it will involve an array function.
You might be able to find something useful at:
http://www.get-digital-help.com/category/excel/searchlookup/
maybe:
http://www.get-digital-help.com/2012/11/29/lookup-and-return-multiple-values-from-a-range-excluding-blanks/
or:
http://www.get-digital-help.com/2012/03/28/search-for-a-text-string-and-return-multiple-adjacent-values/
I don't know if you'll be able to format it exactly the way you're showing but you might be able to at least achieve so results.

Resources