Trying to create a 'FPL' style results table - excel-formula

I want to be able to add results into a sheet from my football league and have that automatically add up things like, Games Played, Won, Lost, Drawn, Goals For, Against, Diff and finally, points.
My first hurdle is Games Won.
I want to look at Column B on Sheet 1 and see if it matches the team name, say Team A.
If it does AND the result in column C is greater than that of column D, then I want to add a one to the games won tab. I also want to do this is column E matches the team name and therefore column D is greater than C.
I can share a copy of my sheet if that is easier to see what I am proposing here, as there may be a better approach entirely.
I am doing this in the Web Based Office 365 Excel.
I have tried all forms of =(SUM(IF(AND statments, but I can only get it to work against individual rows, as opposed to a whole table of data.

I did this by doing this on a different sheet
=SUM(IF(AND('Scores and Scorers'!$C2>'Scores and Scorers'!$D2,'Scores and Scorers'!$B2=INDIRECT($N$1)),1,0))
So if C2 on the scores sheet is bigger than D2 AND B2 matches the name of the team in M1 (N1 simply says M1, and M1 says the team name), then it will put a 1.
I then repeated this 50 times (25 games, so 25 times with B2 matching the team name and 25 times with E2 matching incase the team name is entered on the other side of the score) and then summed the results at the top.

Related

VBA Matching multiple instances of the same name to see if salary amount matches, and whether there are two or more that were paid same amount

I am very new to VBA, having compiled my first two macros only two days ago for the purpose of bank statement reconciliation. My issue though is that I've realized the next step is too complex for me to code myself, and I can't seem to find adaptable code.
I need to take a name, find it in a master file of about 600 names, and see whether it finds a match. The problem them is, frequently there will be two or more individuals with the same name that were either paid different amounts, or were paid the same amount.
I am looking for some help on how to approach this, what functions I would need to use and whatnot. Alternatively, if someone were willing to write this macro for me, I would be happy to Venmo them $10 for the help (by sending your handle to a temp email), as well as of course put a tick next to their answer. I've laid out logical process as I envision it below.
As the data is proprietary, above is a quick example of the data I made. On the left, we have the cleaned bank statement data, with the names in one column and their corresponding salary amounts in the next column. On the right is the master file where we want to reconcile. First off, we are searching only first names as that's how they show on the bank statement, they're Afghan names so the most duplicates we'd get is ~7. Second, a quick note is that the search needs to take place by period, which is a number from 1 to 9 in a column where a number corresponds to a month/bank statement. Here is the logical process:
Take name, i.e. John, from column D in the left spreadsheet (AKA statement), and search through names in column G in the right spreadsheet (AKA master file).
For each name (in period 1): does name match?
If no, keep cycling until a match is found.
If no match is found, move on to next name in statement.
If yes, does the salary amount in column E of statement match with that name's corresponding salary amount in column AV of master file?
If no, keep cycling through all of the names in master file until either a salary amount match is found, or move on to next name in statement.
If yes, it does match, continue to cycle through all names in the master file to check whether there are any other individuals with the same name, and if so, whether one or more of them were paid the same amount.
If an individual does not share their name with anyone else, and the salary amounts in both spreadsheets match, put an "a" in column X.
If an individual shares his/her name with one or more others but his/her salary is unique, put "a" in column X.
If 2 or more individuals with the same name were paid the same amount, put the COUNT of these individuals in column Y. (just marking the instance with a "b" in column Y would be okay too). Ideally, this count would be put next to every instance that 2+ individuals with same name paid the same amount was found.
It looks like the code might be pretty clunky and slow, but all I need is for it to work, doesn't need to be efficient, given that it's all terribly tedious to do manually.
Any help with this would be extremely appreciated.
Based on your description and screenshots, it looks like you can solve this relatively easily with two COUNTIFS formulas (no VBA required). In the following example, I'm going to assume that your cleaned bank statement data is in a separate excel workbook named "Bank Statement.xlsx", and the period data in your master file is in column "A":
The first step is to compare the First Name (column G) and Amount Paid (column AV) in your master file to the data range in your bank statement file (column D and E respectively) and count the number of times both are a match (anything greater than 0 indicates a match). In your master file, type the following formula in cell "X2":
=COUNTIFS('[Bank Statement.xlsx]Output'!$D$83:$D$88,G2,'[Bank Statement.xlsx]Output'!$E$83:$E$88,AV2)>0
The second step is to find any duplicate records in your master file where the Period (column A), First Name (column G) and Amount Paid (column AV) are the same. In your master file, type the following formula in cell "Y2":
=COUNTIFS($A$2:$A$6340,A2,$G$2:$G$6340,G2,$AV$2:$AV$6340,AV2)>1
The third step is to check if both conditions are TRUE. Insert another column in your master file (column Z) and type the following formula in cell "Z2"):
=AND(X2,Y2)
The final step is, of course, to copy the formulas in cells X2, Y2, and Z2 all the way down to the bottom of your data (row 6340). You can now filter by column Z to show only records with a value of TRUE.
Please note the position of the dollar ($) signs in the above formulas. They are essential to maintain the proper range references when copying the formulas down to the bottom of your data.
Hopefully you can adapt this example to fit your actual excel workbook.
Cheers!

Nested COUNTIF in a IF formula for text or generic values

Have this formulera that doesn't work for me but does for a friend who seems to have the same version of excel as me in the same language
It goes:
=OM(B2=B1,"",ANTAL.OM($B$2:$B$65000,B2))
In english:
=IF(B2=B1,"",COUNTIF($B$2:$B$65000,B2))
Where B column is company SSN.
B2 = first company SSN.
$B$65000 = last row to match. In this case 79000+.
The purpose is quite simple. I want a column that shows how many times a value is repeated in column B. Each time it occurs in B, it's to be presented in this column.
For instance, with this formula my friend gets 4 when a company SSN is listed 4 times in the B column, on each row in the column the formula was pasted.
We are talking about a sheet with 79000+ rows, knowing each range for each company is not an option.
For the life of me I don't get why it's working for my friend but not me.
Edit: Here is sample data. I can't show when it's not working because I can't save the file with this formula. Regnr = Company SSN, Column B.
Sample data
Link to a working screenshot in swedish from my friend where OM is IF and ANTAL.OM is COUNTIF
Working example

Key words and sum equations

Sample Page I have a spreadsheet That I am having trouble getting a formula running.
I have a table that has a handful of columns, being brand, description and sales.
I need to get a formula that will automatically find a keyword in column A and B and SUM all the totals to transfer to another worksheet.
Example I have 2 similar products by name, Demo Firm, and Demo Soft. I have them sorted into text to columns to make it easier to search. Demo in the 1st Column, Firm in the 2nd, Sales in the 3rd.
I need to be able to search all of column A and find every word "DEMO", then I need the formula to Search Colum B and Find all the "Firm", finally I need it to sum up the totals of Column 3 of "DEMO FIRM" and place the sum into Column4.
I have tried IFSUM, IFSUMS, and DSUM but I think I am missing one little step.
I hope this makes sense, in my head I know what I want to do, explaining it is difficult.
Thanks for your help. Will keep an eye on my email if further info needed.
I have uploaded an image of what I am needing (SAMPLE PAGE at top of post). The formula that was commented worked for a my small sample. I just need to make sure it will work on an ever changing spreadsheet.
If it is assumed that your data fills rows 2-10, i.e. A2:A10, etc., but obviously this can be changed as needed. As I understand it, you want to sum up all sales into Column D, based on the values in Column A and Column B. You can simply use a SUMIFS formula in Column D, in this case D2 and drag down for all rows, as follows:
=SUMIFS($C$2:$C$10, $A$2:$A$10, A2, $B$2:$B$10, B2)
So if A2 contains DEMO and B2 contains FIRM, then this formula will sum all of the sales totals in Column C where Column A contains DEMO and Column B contains FIRM.

excel - advanced vlookup or other formula?

I have a question regarding excel and I am looking for a formula that can help me transport my data from one sheet to the other. I have some experience with excel, however I am not a pro at it, so I apologize if this is a very trivial question but would also be happy since that would mean it probably has a very trivial answer! Unfortunately I do not have enough reputation points yet to post images, but I will try to explain it as clearly as possible.
Basically I am creating an excel template and the goal is to have 2 sheets in excel.
In the first sheet I have a column with following input in rows A1 - A3: Sales Region,
Country, Account ID's.
Above is the example of column A; from column B --> x; I will put e.g.
Americas, US and as many account numbers as there are in that specific country.
However on the second sheet it gets a bit complicated. My goal is that all the account numbers from sheet 1 irrespective of their sales region and country (which also means irrespective of their column) will automatically be listed on the second sheet.
The second sheet will be organized in the following way:
From column A - C; sales region, country and account ID.; from column D - x financial information for each account.
As a first step I want all the different account ID's from the different columns on the first sheet to be listed under column C (account ID's) on the seconds sheet.
As a second step I want column A - B to be automatically filled out according to account number by accessing the information in which column and thus sales region and country the account is in on sheet one.
I don't think a simple vlookup would do the job, especially for step 1, since I want the account ID's from many different columns and rows in sheet 1 to be listed in just one column....
hope it is clear enough! Would appreciate any help! :) thanks in advance!
The first step take all of column A and copy it to the 2nd sheet on column C.
Select data ribbon and select remove duplicates.
For column A insert vlookup for column C for all the data in 1st sheet
For column B insert vlookup for column B for all the data in 1st sheet
Those value will work well only if an ID has one valid Region and country.
Now just use custom sort to sort it in the way you desire.

Excel: Multiple Vlookups to pull in 1 data element

I have 2 separate sheets in Excel. On sheet 1, I am using the following if statement in column C (hours) to pull in a number in column D (hours) from sheet 2.
=IF(ISERROR(VLOOKUP(A2,Sheet2!A:D,1,FALSE)),"N/A",VLOOKUP(B2,Sheet2!A:D,4,FALSE))
The first vlookup is validating the project number on the second sheet, then the second vlookup is validating the team name and pulling in the hours from the second sheet.
The problem is that when I copy the formula down the column, the hours value repeats for the same team name. Does anyone have any suggestions?
Sheet 1
columns
Proj_Number Team Name Hours
123456 R&D 26
123456 Dev 50
123456 QA 10
777777 R&D 26
Sheet 2
Proj_Number Team Name Organization Hours
777777 R&D AUTO 26
123456 DEV AUTO 50
123456 QA AUTO 10
123456 R&D AUTO 20
You are asking VLOOKUP to do something that it cannot do. The second VLOOKUP in your IF formula:
VLOOKUP(B2,Sheet2!A:D,4,FALSE)
is being asked to return the first instance of 'Team Name' that it finds on sheet 2; which it is doing.
If you want to return the number of hours based on the 'Team Name' and 'Proj_Number', you need to do it a bit differently.
One way is to create another column on Sheet2, maybe called 'Proj_plus_Team', (inserted at column C location) that concatenates the values in 'Proj_Number' and 'Team Name'. Then you can search on this new column using the following formula:
VLOOKUP(A2 & B2,Sheet2!C:E,3,FALSE)
Also, when doing this, make sure that the data on Sheet2 is sorted alphabetically on the values in column 'Proj_plus_Team'. VLOOKUP requires that the search column be sorted alphabetically or inaccurate results may be returned.
Option 1 - using formulas
LOOKUP is designed to retrieve a single value, which is what it's doing. It loops through a data range, checking whether the value is bigger/smaller than the reference value, and retrieves the first transition point. In your case, it finds the first match and stops, not what you're after at all.
If you want to do this using formulas, you'll probably find SUMIF() and the newly added in 2007 SUMIFS() to be a much cleaner route. Also, side-note, in Excel 2007 Tables are your new best friend, they tidy the formulas for this kind of thing right up and look after things like expanding ranges.
Your example above, using tables, would be translated to:
=SUMIF(Table2[Team],Table1[[#This Row],[Team]],Table2[Hours])
where Table1 is the equivalent of your Sheet1, and Table2 maps to Sheet2
Of course the reason that this won't provide what you're after is that this is summarising by team only, whereas you want to apply 2 filters, so you'd move to SUMIFS() and end up with:
=SUMIFS(Table2[Hours],Table2[Proj_Number],Table1[[#This Row],[Proj_Number]],Table2[Team],Table1[[#This Row],[Team]])
The benefit is that your formula will always recalculate automatically, the downside is that you have to manually update your Table1.
Option 2 - pivot tables
Insert --> Pivot table will create your pivot table, set the range as appropriate.
Then drag Project Number into Row labels, drag Team name below it also in Row labels, and drag Hours into the Values box.
That'll give you a breakdown by project by team of how many hours. You can then mess around with the options to get it exactly how you want, by doing things like turning off the level 1 summaries. Those kind of options are best found by experimentation, they live in the PivotTable Design tab. The catch is the need to manually refresh the pivot table, the benefit is that when you add new projects they'll be taken care of easily.

Resources