Count IF multiple criteria/data types match - vba

I'm looking to generate a report to list the number of Cities/Towns that don't meet a certain criteria so on Sheet 2 I have an alphabetical list of all the cities/towns.
I want to do a look up/count if function to state if A2(Sheet 2) can be found anywhere in Column D on Sheet 1 then count it if the date in column L (sheet 1) matches the date in Cell $E$1 (sheet 2) and Column A in Sheet 1 is greater than zero.
I originally done this formula but it is returning an error.
=COUNTIFS(PickData!D:D,Sheet1!A2,PickData!L:L,Sheet1!$E$1,PickData!A:A,PickData!A:A>0)
Is there any other formulas that I'm currently not thinking of? Or is it possible to do this via VBA and it returns the value in to column B either True if it matches or False if it doesn't?
Thanks
Al

The problem with your previous formula is in the final criteria. Update to:
=COUNTIFS(PickData!D:D,Sheet1!A2,PickData!L:L,Sheet1!E2,PickData!A:A,">0")

Related

Can't figure out what this line does

Can someone please tell me what does this line do:
ActiveSheet.Range("AH1").FormulaArray = "=iferror(MATCH(1,(plan!T3:T20000=AF1)*
(plan!W3:W20000=MONTH(E1)),0),0)+2"
plan is a name of sheet in my Excel file. thanks in advance.
The formula is a doing a multi-criteria CountIF. Without seeing the data, it is doing the following.
Count the data in column T if any of the rows match what is in cell AF1, but only count it if the corresponding month shown in Column W matches the Month shown in cell E1. Then add 2.
this add array formula (usually inserted with Ctrl+Shift+Enter) to the cell AH1. It seems that formula checks if value in column T in plan sheet is equal to this one in AF column and month of date in E column equals to value in plan!W column, plus 2 for some reason.

Excel 2013 conditional formatting using a formula

I have a spreadsheet in Excel 2013 with Location in Column A, Material Number in Column B and types or groups of materials sorted by material number in Column I J & K. Other columns contain data that is irrelevant here.
Column B can contain the same material number in multiple cells.
I'm trying to find a simpler way to format font and color of the items in Column B by comparing if the item is located in Column I J or K, or not at all (no formatting in that case).
I was entering an individual conditional rule to compare Column B with the value in cell I3, another rule for I4, another rule for I5 and so on.
This is getting unwieldy due to the number of items now in I J & K.
There has to be a simpler, more elegant way to do this. Conditional formatting using exact match is not letting me select a range of cells for the match value.
I just need to format the text in Column B to Bold and Blue if the number exists in Column I also, or Bold and Red if it exists in Column J or Bold and Green if it exists in Column K.
Set up a conditional formatting rule that uses a formula. The formula can contain a Countif function that counts how many times the value in cell B in the current row is counted in column I. For example, starting in row 2, select B2 and add a formatting rule with the formula
=COUNTIF($I:$I,$B2)
Take care to use the current row number in the formula and don't use a dollar sign $ in front of the row number. Set three rules, one for column I, one for J and another one for K.
You don't need a new set of rules for each row. Just apply the three rules to all the rows required.

Using CONCATENATE to populate a sum formula in excel vba

I have a spreadsheet that has numbers for a particular year and then subtotals for that year.
The number of instances in a year can vary and there may be a year that doesn't exist i.e., 2018 might be skipped. The title of the totals row is always "FYXX Totals." I have a for loop that goes through the entire column and looks for "FY" Then if it falls within one of three categories (FY1-FY2, FY3-FY7, FY3-FY9; these being variables that represent a year). What I need is for the loop to sum the number in column D, E, F...when "FY" is found. I think using CONCATENATE might be the way to go but I am not sure a) exactly how to do that or b) if that is even the best way to go about it.
Dim rng As Range
Dim SumRow As Integer
Set rng = Range("C4:C" & NextRow)
For Each cell In rng
If Left(cell.Value, 2) = "FY" Then
If 2000 + Int(Mid(cell.Value, 3, 2)) <= FY2 Then 'This is the if statement for the fisrt category
'Here would be the sum function when the if statement is triggered
End If
End If
Next cell
Thanks so much for the help.
SpreadSheet_Picture
The second if loop (right now written for the first category) would need to sum the just the zero that is in column D next to FY17 Total. Keep in mind that sometimes row for FY18 may exist so this macro would have to be able to grab that as well should it exist. But in this case what would have to go into cell "D" & NextRow would be =SUM(D5).
My best attempt at understanding what you're after is that you want to place a formula in each cell of column D where the cell in column C contains FYxx Total, where xx meets certain other criteria. That formula should contain the sum of all the cells in column D for which the cell in the corresponding row of column C contains the same value of FYxx.
The easiest way I can think of to achieve this is to use the SUMIF function:
The formula =SUMIF(B$2:B$999,LEFT(C3,4),D$2:D$999) in cell D3 calculates the sum of all cells in column D where the cell in the corresponding row of column B matches the criterion, i.e. is equal to the first four characters of cell C3.
Unless there are further instances of the same FYxx value elsewhere in column B, the ranges in the first and third arguments of the SUMIF can cover the whole table, which I've assumed here extends to row 999, so you can keep those the same for each cell you place this formula in. You only need to change the row for the cell in column C in the second argument.
In fact if you really want, you can place exactly the same formula in each Total cell in column D:
=SUMIF(B$2:B$999,LEFT(INDEX(C$2:C$999,ROW()-1),4),D$2:D$999)
Here the INDEX function looks up the appropriate cell in column C based on the row of the cell that the function is placed in.

How to compare a list of rows to another list of rows in Excel?

I am trying to figure out if there are any differences between a list of data with another. In order for a row of data to "match" with another row, the row must have the same values in their corresponding column. The rows themselves do not have to be in any particular order. In particular, I am dealing with a parts list, where there are part numbers, descriptions, etc. I am trying to figure out if any rows of data are different from rows of data from another list.
I found Compare two sheets using arrays, which may have the answer to my problem, but I am having trouble figuring out how to adapt to my code due to inexperience in Visual Basic.
I was able to get it to work for a single column of data, comparing one column of data from one sheet to another, but cannot get it to compare entire rows of data.
Here is an example of I want this to work:
Sheet 1 Sheet 2
Column 1 Column 2 Column 1 Column 2
Row 1 22a 33 11 11
Row 2 22a 33a 22a 33
Row 3 55 22b 55 23b
The code in the link will tell you what is not in sheet 1 but in sheet 2 and vice versa. In this example, I would like the code to tell me Sheet 1 Row 2 and Sheet 1 Row 3 are not in Sheet 2, and Sheet 2 Row 1 and Sheet 2 Row 3 are not in Sheet 1 (Sheet 1 Row 1 and Sheet 2 Row 2 match).
If that is ok by you, you can do it without VBA using the following formula:
={IF(IFERROR(MATCH(A1&"|"&B1;Sheet7!$A$1:$A$3&"|"&Sheet7!$B$1:$B$3;0);-1)=-1;"Unique";"")}
Assuming that each of your tables start in A1 (so that the tables with three entries span A1:B3), and entering this formula into C1 (and copying it down), press CTRL+SHIFT+ENTER when entering the formula to create an array formula, this will show the word "Unique" in column C if the pair in that row on that sheet is not in any of the row-pairs on sheet 2.
You can then use conditional formatting to highlight unique rows, filter on the tables to include only unique rows, or some other way of doing what you need.
NOTE 1: I have entered my numbers in Sheet6 and Sheet7 instead of 1 and 2. The formula written above goes into Sheet6.
NOTE 2: My language use ; instead of , as function separator, so if yours use , you need to change that.
NOTE 3: You will need to expand the ranges Sheet7!$A$1:$A$3 and Sheet7!$B$1:$B$3 if your set grows (this will happen automatically if new rows are inserted in between the old ones). The best is still probably to create named ranges for each of the 4 columns, exchange the references with those, and manage the named ranges instead of the formulas.
NOTE 4: If your data set contains the character "|", you need to change that as well, to match some character that you for sure do not have there.
Alternatively you could in column C on each cheet enter (assuming first entry in C1)
=A1&"|"&B1"
and copy this down, then run the solution from your copied example using that C column instead of on A1 and B1.

vlookup if name is matched display employee id

Ive never used vlookups i have a spreedsheet not sure if this is the right function. I have two sheets
Sheet 1
first name last name username
Sheet 2
first name last name employee id business unit
I need in column D on sheet 1 to have employee id ive below. Pay no attention to column letters and sheets because i moved to another sheet to try getting this right.
=MATCH(B11,Sheet1!C:C,0)
Any help is much appreciated.
So you realize you have to match both first and last names? There are several ways to accomplish this depending on how many employees you have in sheet 2: a) small list could a two-column search using array formula; b) large list just create another column in both sheets joining last & first names and do a MATCH or VLOOKUP on them.
Since your needs are simple and to illustrate option (b):
Insert a column in both Sheet1 and Sheet2 after the "last name"; you should now have an empty column C in both sheets.
Assuming you have column headers in row one, and thus data starts in row two, set cell C2 in both sheets with function =B2&","&A2, then fill-down that formula on both sheets in all rows.
Set Sheet1 cell E2 to formula =VLOOKUP(Sheet1!C2, Sheet2!$C:$D, 2, False), and fill-down that formula in all rows.
Voila, employee IDs on Sheet1. I do have to say this is so Excel 101. There are all sorts of examples and tutorials on this easily found using even the most trivial Google searches.