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.
Related
Is there a way that I can get all the cells that contain "Student" along with the cell that's below it and put it in another table next to each other?
Maybe this picture will illustrate my problem better:
The main problem is to simply look in a column all the cells that contain "Student" and get the cell right below it too (discard everything else).
Will the best approach be to use VLOOKUP() or the SEARCH(), I'm struggling to create a formula for this small task. Any help would be greatly appreciated.
Just HSTACK two filters, the second with and offset range:
=HSTACK(
FILTER(A3:A17,ISNUMBER(SEARCH("Student",A3:A17))),
FILTER(A4:A18,ISNUMBER(SEARCH("Student",A3:A17))))
^^^^^^Note the offset
With irregular spacing:
This answer is based on your previous thread, I can update the formula's if needed but I am guessing this example above is just an example?
This will require a helper column to my understanding, in order to trim out the fat.
B1
=IFERROR(FILTER(FILTER(A1:A1000,NOT(ISNUMBER(FIND("titanium",A1:A1000)))*NOT(ISNUMBER(FIND("beagle",A1:A1000)))*NOT(ISNUMBER(FIND("legend",A1:A1000)))*NOT(ISNUMBER(VALUE(LEFT(A1:A1000,FIND(".",A1:A1000)-1))))),FILTER(A1:A1000,NOT(ISNUMBER(FIND("titanium",A1:A1000)))*NOT(ISNUMBER(FIND("beagle",A1:A1000)))*NOT(ISNUMBER(FIND("legend",A1:A1000)))*NOT(ISNUMBER(VALUE(LEFT(A1:A1000,FIND(".",A1:A1000)-1)))))<>0),"")
C1 Required to be dragged down for X number of cells
=IFERROR(INDEX(FILTER(IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000),IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000)<>0),ROWS(C$1:C1)*2-1),"")
D1 Required to be dragged down for X number of cells
=IFERROR(INDEX(FILTER(IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000),IFERROR(LEFT(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)),LEN(RIGHT($B$1:$B$1000,LEN($B$1:$B$1000)-FIND("/",$B$1:$B$1000)))-1),$B$1:$B$1000)<>0),ROWS(D$1:D1)*2),"")
B1 will filter the data, and cells C1 and D1 will strip out the text you are looking for.
I know am late to the party, but you can try this something along the lines using TAKE(), TRANSPOSE() & WRAPCOLS()
• Formula used in cell C3
=TAKE(TRANSPOSE(WRAPCOLS(A3:A17,5)),,2)
Note: This works if the spacing is consistent.
For Irregular Spacing using XLOOKUP(), FILTER() & HSTACK()
• Formula used in cell H3
=LET(_Student,FILTER(F3:F17,ISNUMBER(SEARCH("Student",F3:F17))),
HSTACK(_Student,XLOOKUP(_Student,F3:F17,F4:F18)))
I have two columns A and B, If A Column have the specific value "High" then the corresponding cell in B Column should contain the Date (dd/mm/yyyy)value otherwise if date value is not available the cell should be highlighted as Red. I am new to this macro and I am not able to find the logic for this.
Sorry this isn't a comment, but I don't have sufficient rep.
I'm a little unclear how dates are populated in column B. Is this something we can take as given or are you assigning dates somehow? It might help if you could share a bit more about the structure of the sheet, maybe some "dummy data"?
That said, this sounds like a straightforward case of loops + conditional statements. I doubt this will work for you out of the box, but you could try nested For loops over columns A and B à la:
For Each cell in Range("A:A")
If cell.Value = "High" Then
If IsEmpty(Range("B"&cell.Row)) Then 'IsEmpty tests whether the cell is empty, you may need to change this if the cell has some other value in it
Range("B"&cell.Row).Interior.Color = 255 '255 corresponds to the color red
End If
End If
Next cell
I agree with Pᴇʜ though, you don't actually need VBA for this at all. You can apply conditional formatting using a formula for the rule and then use a formula like this for the cells in column B:
=IF(A2="High",IF(ISBLANK(B2),TRUE,FALSE),FALSE)
Then just make sure you apply the formula to all the rows you care about.
I have a range of value (say H6:H20) containing values "g","y" or "r".
In order to count each status and use that as the source of a donut chart, I made a range of 3 cells calculating =COUNTIF($H$6:$H$20,"Green") etc...
Then I tried to be more elegant and create a single array formula returning the count for each letter, that I could eventually use as the source of my chart, without having intermediry calculation range. But I can't get this working.
Input:
g
r
y
g
g
r
g
g
y
Expected output (with a single array formula):
5
2
2
My try: =COUNTIF({"g","y","r"},$H$6:$H$20) -> error
Other try: =SUMPRODUCT(1*$H$6:$H$20={"g","y","r"}) -> error
(both entered in a 3 cells range with Ctrl+Shift+Enter, of course)
What is the right formula ?
You don't need an array formula, though you do need to store that formula as a Defined Name within Name Manager, e.g.:
Name: Series_Values
Refers to: =COUNTIF(Sheet1!$H$6:$H$20,{"g","y","r"})
Change the sheet name (Sheet1 here) as required.
You can then add a series to a chart with the following syntax for the Series values entry:
='Sheet1'!Series_Values
Again, amend the sheet name as required, though be sure to retain the exclamation mark and apostrophes (the latter are not strictly necessary if the worksheet name contains no spacing, though in any case it is good practice).
Excel will actually amend this to:
=Book1!Series_Values
(where Book1 is the assumed workbook name), though this is not important here.
Regards
That's what FREQUENCY function is for. Select 3 cells and CTRL+SHIFT+ENTER following formula:
=FREQUENCY(MATCH($H$6:$H$20,{"g","y","r"},0),MATCH($H$6:$H$20,{"g","y","r"},0))
Assuming this isn't dynamic, and you have a definite amount of rows, you can use the following. Let's say you're putting this formula in row 20:
=COUNTIF($A$1:$A$9,INDEX({"g","r","y"},ABS(20-(ROW()+1))))
and drag down.
Edit: If you want in the same cell, just combine COUNTIF()?
=COUNTIF($A$1:$A$9,"g")&","&COUNTIF($A$1:$A$9,"r")&","&COUNTIF($A$1:$A$9,"y")
=IF({"g","y","r"}="g",COUNTIF($H$6:$H$20,"g"),IF({"g","y","r"}="y",COUNTIF($H$6:$H$20,"y"),IF({"g","y","r"}="r",COUNTIF($H$6:$H$20,"r"))))
long solution as I don't have time to make a more elegant one. You can see the array object with F9 in the formula bar.
I'm working on a budget for a project with multiple phases. There is a possibility that not all phases will be worked on so I've added some lookups and SUMIF formulas so that I can get a summary of my included and excluded effort and dollar amounts. That all works fine. Now I'd like to hide my row of lookups (row 1), but still have a way of identifying which phases of the project are included and which are excluded. Obviously I could manually concatenate them together, but if the phases being included/excluded change then I need to remember to update those formulas (and it's not nearly as fun as doing all in a formula). Here's how my sheet looks:
The TEXTJOIN function seems like it should work (i.e. =TEXTJOIN(CHAR(10), TRUE, C2:N2)), but I can't wrap my head around how to make the range parameter dependent on my lookup row. I played around with INDEX using something like =TEXTJOIN(CHAR(10), TRUE, INDEX(A2:M2,,(A1:M1="Yes")*COLUMN(A1:M1))), but didn't have any luck. At the end of the day I want to have something like:
Phase 1 Phase 2 Phase 5
Please note that the above data should all appear in the same cell - using the line feed character, CHAR(10), as the delimiter in the TEXTJOIN function will make all of the phases appear on a new line within a single cell. I do not want to fill formulas through multiple cells. Thanks in advance for any help.
Please take a look at the picture. I had a similar issue in the past (and brought it to StackOverflow, at which point I was helped by #ScottCraner, original post here:
Doing an array formula lookup
Basically,
1) You set up the array you are looking through - in my case, its $A$2:$A$6, in your case it will be $B$2:$M$2.
2) You then nest the COUNTIFS function inside of a match function. The function does the following:
A) It checks whether the name of phase X has already shown up in column E when you are copy/pasting down
B) If it has, move on to the next one
C) If it hasn't, output
3) Of note: this is an array formula, so the formula itself is checking through every cell. So it looks at cell A2; if the cell in B2 is "Yes", and "Phase 1" isn't in range in column E, then put in phase 1. Because it is, its there. Then it looks at cell A3; if the cell in B3 is "Yes", the same thing for phase 2. Then it looks at cell A4; because B4 is "No", the *(B2:B6="Yes") will throw an error. and so on
4) Place error catching brackets around the function.
A less elegant way to go about this, which doesn't require array formulas would be to use the secondary column's "Yes/No" as an index. This assumes the value in the secondary column is redundant- and repeating the primary column's "Yes" or "No."
In C1: =CONCATENATE(B1,COUNTIFS($A$1:B1,B1)) -
Repeat relatively for E1, G1, etc.
Somewhere separate (the below formula assumes Row 1 of the same worksheet), you could then use: =IFERROR(INDEX($2:$2,MATCH(CONCATENATE("Yes",ROW()),$1:$1,0)-1),"")
To look up "Yes1", returning "Phase 1" and autofill downward. IFERROR is used here to return blank when you run out of "Yes" results.
Each row of 4 columns represents a set of data
A1 : D1 1,2,3,4
A2 : D2 4,2,1,5
A3 : D3 5,3,2,1
etc.
Now the column set will be compared to another column set
F1 : I1 4,6,3,1
F2 : I2 4,3,2,1
F3 : I3 2,3,5,1
The set that matches to the other column set will be marked red. So in the example F2:I2 and F3:I3 will be marked red. They just need to contain the same numbers. The order is not important but all numbers should match.
I thought of using conditional statements but can't seem to find a way to compare and match sets of range to other sets of range.
As an alternative, I thought of adding all the columns =A1&" "&A2&" "&A3&" " &A4 then sort it then match it from there but I tried sorting from left to right the sets and it doesn't seem to be sorting right if I do it all at once. The sheet will contain a large amount of rows so that will be a chore to do it 1 by 1.
So I'm out of ideas as I am not that good with excel. :(
Appreciate all the help I can get. :)
Also, I don't mind learning other languages if it makes things easier. (as long as I can import the data from an excel)
If you want to create a single column to match on then this should do it:
=CONCATENATE(LARGE(A1:D1,1),":",LARGE(A1:D1,2),":",LARGE(A1:D1,3),":",LARGE(A1:D1,4))
Then you can use the regular lookup functions such as MATCH()