I have multiple spreadsheets in a workbook and I would like the following in basic English talk:
IF worksheet1(cell)A3, appears in 'worksheet2' column B - count how many times it appears in column b 'worksheet 2'
So in other words - Lets say A3 = BOB smith - in work sheet 1
and appears 4 times in worksheet 2 - I want the formula to count the fact that A3 'Bob smith' is in worksheet 2 4 times, and come back and tell me 4.
I have attempted to do separate calculations - with use of Vlookups - then in another cell to count/do if statement
for example
=COUNTIF(VLOOKUP(A9,'To retire'!J:J,9,1))
=IF(J228=O233, 'worksheet2'!F440,0)
=VLOOKUP(A3,'worksheet2'!A:A,1,1)
Help would be very much appreciated, I am very stuck - I am unsure if I am looking into this too deeply or not enough! Thank you in advance
This is trivial when you use SUMPRODUCT. Por ejemplo:
=SUMPRODUCT((worksheet2!A:A=A3)*1)
You could put the above formula in cell B3, where A3 is the name you want to find in worksheet2.
=COUNTIF() Is the function you are looking for
In a column adjacent to Worksheet1 column A:
=countif(worksheet2!B:B,worksheet1!A3)
This will search worksheet 2 ALL of column B for whatever you have in cell A3
See the MS Office reference for =COUNTIF(range,criteria) here!
You can combine this all into one formula, but you need to use a regular IF first to find out if the VLOOKUP came back with something, then use your COUNTIF if it did.
=IF(ISERROR(VLOOKUP(B1,Sheet2!A1:A9,1,FALSE)),"Not there",COUNTIF(Sheet2!A1:A9,B1))
In this case, Sheet2-A1:A9 is the range I was searching, and Sheet1-B1 had the value I was looking for ("To retire" in your case).
Try this:
=IF(NOT(ISERROR(MATCH(A3,worksheet2!A:A,0))),COUNTIF(worksheet2!A:A,A3),"No Match Found")
If your are referring to two worksheets please use this formula
=COUNTIF(Worksheet2!$A$1:$A$50,Worksheet1cellA1)
In case referring to to more than two worksheets please use this formula
=COUNTIF(Worksheet2!$A$1:$A$50,Worksheet1cellA1)+=COUNTIF
(Worksheet3!$A$1:$A$50,Worksheet1cellA1)+=
COUNTIF(Worksheet4!$A$1:$A$50,Worksheet1cellA1)
Related
I have a worksheet that detects toxic combinations (two variables that are not supposed to exist together). In one sheet I want to cross all the variables there are and highlight the cell that crosses the two variables that are toxic.
for example cell E1 (variable 1) and A5 (variable 2) are toxic combinations, so i want to highlight cell E5 (this can be with a X or a formatting conditions, it doesn't matter).
On another sheet these toxic combinations are defined, simply by entering the two variables behind each other on the same row.
I'm having trouble understanding how to approach this. one thought is to enter a formula (if such exists) that goes something like the following:
=IF cell E1 and cell A5 are on the same row in worksheet ... then x else ""
So my question is: does anyone have experience with this situation, if so, how would/ did you tackle this. Or is there a formula that I can use demonstrated above? Or is it wise to use VBA?
Please let me know if anything is unclear.
Edit: screenshots
The worksheet where the toxic combinations are determined:
The worksheet where the toxic combinations are 'visible'
you can use vlookup for this.
Suppose in your SOD matrix, the element names are in column A and in row 1, and that in your SOD description the elements are in column C and E. And suppose that your SOD description is on a tab called "SODdesc"
the formula in cell C5 would be
=if(VLOOKUP($A5;SODdesc!C:E;3;0)=C$1;"TOXIC";"")
This only works if there are no duplicates in column C of the SOD description sheet.
Another possible solution that works also if there are duplicates, is to create an extra column (G) where for example G10 would be =C10&E10 and a column H, with H10 is =E10&C10
then the formula in C5 would become:
=if(not(isna(vlookup($A5&C$1;SODdesc!G:G;1;0)));if(not(isna(vlookup($A5&C$1;SODdesc!H:H;1;0)));"TOXIC";""))
I didn't create a whole file to test the formula's, but if you know a little bit how excel formulas work, you should get the idea.
I currently have a large nested IF statement that uses a helper cell (C1) to dictate which formula to utilize based on numbers 1,2,3,5 & 6. Specifically, one IF statement within the larger nested IF statement needs to be updated for instances when there is a blank cell in column A. Here is how my workbook is setup:
Data Tab
Bonus Tab
Summary Tab
This is my current formula in Column B:
=IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
What I am looking for is when cells in column A are blank, than the corresponding cell in Column B would be 0. Again, the formula above has to remain in the =IF(Data!$C$1=2, format since it is part of a larger nested IF statement.
Answer I am seeking:
Thank you for looking!
Try this:
=IF(Summary!A2="",0,IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2))
How about adding an IF in there like this?
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,1,0)*
(IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$2))
or like this
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,
IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$,
0))
What about:
=IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
I realise this gives you FALSE rather than 0 at the end, but I don't know what the rest of your 7 IF statements look like.
EDIT
Based on #AlexisOlson 's comment:
=1*IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
This now returns 0 when Column A is blank, as required.
IFERROR(INDEX($I$7:$I,MODE(IF($I$7:$I<>"",MATCH($I$7:$I,$I$7:$I,0)))),"No data")
With this formula, which calculates the most common text value, I need to have the 2nd most common.
Column I content:
Apple
Orange
Apple
Apple
Orange
In this example, I need to get Orange. How is that possible? I can't figure how.
A PivotTable might suit:
and copes with ties for rank.
You can extract the most frequent item in the list with an array formula.
=INDEX(MyList,MATCH(MAX(COUNTIF(MyList,MyList)),COUNTIF(MyList,MyList),0))
Note that an array formula must be confirmed with Shift+Ctl+Enter instead of the customary singular Enter required for normal formulas. When entered wrongly it will display a #NUM! error.
For simplicity's sake I have used a named range MyList in the formula. However, if you prefer, you can replace the name with something like $I$7:$I$1000.
To extract the second-most frequent expression in the list you could use a formula constructed analogue to the above.
=INDEX(MyList,MATCH(LARGE(COUNTIF(MyList,MyList),MAX(COUNTIF(MyList,MyList))+1),COUNTIF(MyList,MyList),0))
This formula is built on the logic that n equals the highest number of occurrences. Therefore the second highest must rank as n + 1, being MAX(COUNTIF(MyList,MyList))+1) in the above formula. By the same method the third ranked could be extracted.
You can embed these formulas in an IFERROR() function.
I found this on Mr Excel
Return most common, 2nd most common, 3rd most common, etc. text string in an array
Spreadsheet Formulas
Cell ___ Formula 'Notice that the cells are B2, D2, E2. Column C is blank
B2 =IF(A2="","",IF(COUNTIF(A$2:A2,A2)=COUNTIF($A$2:$A$100,A2),COUNTIF($A$2:$A$100,A2)+(ROW()/1000),""))
D2 =IF(ROWS($1:1)>COUNT(B:B),"",INDEX(A:A,MATCH(LARGE(B:B,ROWS($1:1)),B:B,0)))
E2 =IF(D2="","",COUNTIF($A$2:$A$100,D2))<br><br>
Results
___ A ________ B ___C ___D _________E
1 Data Set:___Helper ____ Name ____ Occurrences
2 Harmon _____________ Williams ______4
3 Smith _______________ Smith ________3
4 Smith _______________ Harmon ______2
5 Harmon_____ 2.005
6 Williams
7 Williams
8 Smith _______3.008
9 Williams
10 Williams ____4.010
you can try to tie this all together in a single formula but it's simpler and more agile in a spreadsheet environment to just break out the problem in a few separate steps.
take a given column of values you're wanting to count/rank - i'll call it RankList in examples below.
if you're not setting named ranges (do yourself a favor and use named ranges) you'll want this to be your column range - i.e. A:A
now in another column use
=unique(RankList)
there's your list of unique values, now we just need to count the instances of each unique value in the original RankList - this is simple - in the next column over simply use
=countif(RankList,B1)
B1 above represents the cell adjacent to the formula, wherever that might be on your sheet. now autofill the formula in with the relative cell value for each item. now all of your items are counted by instance.
now we want to sort them by value, highest to lowest. create another named range, selecting the two columns containing the =unique(RankList) and =countif(RankList,B1) formulas that were just created, i'll refer to it as UniqueCount
use the following
=sort(UniqueCount, 2, false)
that's it. again you can accomplish this by stacking formulas like in the above examples, but in practice i've found that you won't know what you'll want to do additionally with your data/sheet later on. keeping it broken up in discrete steps like this makes it much easier to make adjustments.
I have kind of a complicated count I can't seem to figure out. Basically I have a table that looks similar to this image:
Now what I need to do is:
Tally the number of 1's if the category = "Anon" in one cell, then count the number of 2's and 3's in separate cells all if the category = "Anon".
Wash/Rinse/Repeat for if it's "Watterson" and "Davis".
Is there any way I can count the occurrences of 1|2|3 and have it separated by category like this?
Sorry, kind of an Excel noob here. I didn't think pivot tables would be correct though (especially because they want the dates to be columns, plus I couldn't figure out how to insert a conditional). Any pointers in the right direction would be appreciated.
Let's suppose that your screenshot shows cells A1:I6.
Then ...
Add column headings "1", "2", "3" in cells J1:L1
Put the formula =COUNTIF($C2:$I2,J$1) into J2 and copy it across and down
Set up a list of unique Categories (Anon, Watterson etc) starting in A10
Add headings in row 9 like "Category", "Tally of 1s", "Tally of 2s", "Tally of 3s"
Put the formula =SUMIF($B$2:$B$6,$A10,J$2:J$6) into B10 and copy it across and down
My guess is that someone cleverer than I could construct a sumproduct formula for B10 that works without the need for the helper columns J:L.
[Edit] Using Maki's sumproduct formula in my structure, you can scrap helper values in cols J:I and put this into B10 -- =SUMPRODUCT(($B$2:$B$6=$A10)*($C$2:$I$6=B$9))
assuming that you start from cell A1,
=SUMPRODUCT((list name to search for)*(value to search in the data area))
=SUMPRODUCT(($B$2:$B$6="Anon")*($C$2:$I$6=1))
=SUMPRODUCT(($B$2:$B$6="Anon")*($C$2:$I$6=2))
...
=SUMPRODUCT(($B$2:$B$6="Watterson")*($C$2:$I$6=1))
...etc.
The Goal
Basically, I want to compare A6 to range Responses!C:C and return a count of non blanks in columns Responses!F:F
I'm using this formula
=COUNTIF(responses!D:D, "=A6", responses!F:F)
What I've done
In the example, I'm trying to check column D in the responses sheet for a string in cell A6 of the dashboard sheet. If the string exists in the column D of the responses sheet, then I want a count of the items in column F. I expect 0 to be returned for the NJROTC item.
Request
Can someone please review my formula and let me know what I'm doing wrong OR if there is a better solution than the COUNTIF function?
Video Explaining the Problem
http://youtu.be/J_ados6Ksq4
Just a syntax issue; change "=A6" to simply A6 (you could also use "="&A6 but that is functionally no different and more key strokes).
=IF(ISTEXT(VLOOKUP($A6,responses!$D:$M,3, FALSE)),"Yes","No")
This worked for me