Conditional formatting based on two quantity columns (Excel) - excel

I'll try to be as specific as possible.
I want to compare an array of different codes (Quantity Needed). A column that contains the same code multiple times, and each of these needs to be compared to the value of a single cell in another column, that contains that code only once (Stock Qty).
To be more specific,I need to compare the quantity needed of said specific code (which is located in a cell next to the code) to the quantity in stock of said code (which is located in another table).
Then I need said 'Quantity Needed" cell to turn either Green (if the number on the Stock Qty column related to that specific code is equal or bigger than the number on the Quantity Needed cells for that code) or Red (If the number is less).
I could do this with conditionals one by one but the amount of codes is very large.
Image for further comprehension: https://snag.gy/EnzGWc.jpg
Thanks.

You can use conditional formatting with formula. goto conditional formatting=>New rule=>formula. There enter this formula =D3-VLOOKUP($B3,$H$3:$I$10000,2,FALSE)<0 . Set applies to =$D$3:$D$10000. Adjust range to fit all values in columns.

Related

Index Match Formula returns a VALUE error is look up cell has several characters

I am puzzled by this problem.
I have a matrix with different criteria (shown below) which is to be used by users to access themselves, with each piece of criteria reflecting a maturity level. The criteria and the relevant maturity level is stored within a sheet called MasterSheetGrid.
The user selects the option that represents the criteria that they believe they are currently a like, in column J. Column K then performs the follow formula
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J8,$5:$5,8:8)),INDEX(MasterSheetGrid!$1:$50,((MATCH($C8,MasterSheetGrid!$C:$C,0))))))
This formula attempts to look at the user selection in column J, and calculates the criteria that their selection equates to. Then, using the criteria, the formula should look up the criteria within the MAsterSheetGrid and then return the corresponding level from row 5:5.
This formula works and does what i want it to, however, there are some instances where the formula does not work, when the look up/maturity criteria has a large amount of characters. I cannot work out how many characters this is, but the formula does not work if over a certain amount.
Note, i have attempted to replace the XLOOKUP with INDEXMATCH with no luck, i receive the same error. Also, the maturity criteria/user selection is calculated by the formula below
=IF($C8="","",(FILTER(INDEX(MasterSheetGrid!$D:$I,MATCH($C8,MasterSheetGrid!$C:$C,0),0),INDEX(MasterSheetGrid!$D:$I,MATCH($C8,MasterSheetGrid!$C:$C,0),0)<>"")))
MaturitySheetGrid
Formula works correctly due to a small character look up criteria
Formula does not work when the look up/selected criteria has a large amount of characters

VBA code required to loop through different sized rows of data and return MAX value

I am currently automating a dashboard creation and I've hit a bit of a roadblock. I need some code that will go through about 7000 rows of data and return the highest value in a certain column for each specific item. The data is copied from a pivot table and so is broken down into row sections, I have attached a mock of what it looks like.
I need the highest value in Column G for each portfolio, and will need to use the portfolio code (e.g. XY12345 - They are always 7 characters) to map that value to the dashboard.
My issue is, each portfolio has a different number of rows for the values, and some have blank cells between them, and therefore I am stumped. I was hoping to use Column J to count the number of rows for each portfolio (as there are no breaks for the portfolios in this column) and then use a loop to loop through each portfolios rows of values, based off the Column J count, and then return the highest row value for each portfolio. Problem is I'm new to VBA and have been teaching myself as I go, and I've yet to use a loop.
Many thanks,
Harry
If I understand correctly, you're looking for the largest value in Column G.
I'm not sure why you think you would need VBA for this.
Get the maximum value of a column
You mentioned that you're concerned about each column not having the same number of cells but that's irrelevant. as SUM ignores blank cells, so just "go long", or - find the maximum of the entire column.
To return the largest number in Column G you could use worksheet formula :
=MAX(G:G)
The only catch is that you can't place that formula anywhere column G or else it would create a circular cell reference (trying to infinitely add a number to itself). let's pit that formula in cell F1 for now (but anywhere besides column G would do fine).
Find the location of a value
Now that you know the largest value, you can determine where it is using a lookup function such as MATCH or VLOOKUP. Like with so many things in Excel, there are several ways to accomplish the same thing. I'll go with MATCH.
Replace the formula from above (in F1) with:
=MATCH(MAX(G:G),G:G,0)
This will return the row number of the first exact match of the maximum value of Column G.
As for the third part of question: returning the code like X12345 where the value exists, will be a little tricky since your data is not organized in a logical tabular style (tabular meaning, "like a table").
Your data is organized for humans to look at, not for machines to easily read and manipulate it. (See: Office Support: Guidelines for organizing and formatting data on a worksheet)
Basically, when organizing data in rows, all relevant information should be on the same row (not a subjective number of rows behind). Also, you have the number combined with other information.
My suggestion for a quick fix:
Right-click the heading of Column C and choose Insert to insert a blank column.
In C2 enter formula: =IF(B2="",C1,LEFT(B2,7))
Copy cell C2
Select cells in column C all the way to the "end" of your data, where ever that is (not the end of the worksheet). For example maybe you would select cells B2:B1000)
Paste the copied cell into all those cells.
Now, you can again modify the formula in F1:
=INDEX(C:C,MATCH(MAX(G:G),G:G,0))
This will return the value from Column C in the same row that the maximum value of Column G is located.
This is known as an INDEX/MATCH formula.
Hopefully this works for you in the interim until you can organize your data more logically. There's lots of related information and tutorials online.

Subtract one cell from the cell above in Spotfire using multiple columns

How would I create a calculated column that would find the thickness of a cell that is the difference from one cell with the cell above it, but want to do this for many individual wells that have unique identifiers in a column. Additional, the last cell of that well will not have a value because there is not cell below it. On top of that I would like to play with the option of calculating this from deepest to shallowest, or shallowest to deepest so c in a column, and organized by ranking scheme (ascending or descending).
See image attached
Use a calculated column with an OVER statement (provided you're not using an in-database data connection). It will look like this:
Sum([Depth]) OVER Intersect([Well],Next([Depth])) - [Depth]
It will return the same result regardless of the row order because the Next function has built-in alphanumeric sorting which it performs on [Depth].

Concatenated VLookup comparison for conditional Formatting

I'm looking to create a conditional formatting field which will compare the values of two cells on sheet 2, to then format the correct cell on sheet 1.
To give some background, I have a spreadsheet (sheet1) which gets information from (sheet2). (sheet1) concatenates the Assessment period (B4) with the Subject code (AA12) and the Pupil ID (A15) which in turn is used to look up the corresponding field in sheet 2 to get the information.
=VLOOKUP(CONCATENATE($B$4,AA$12,$A15),sheet2!$F:$M,7,FALSE)
Here, Column F in (sheet2) holds the concatenated field names and column L holds the Grade, I.e A,B,C etc.
Column M in (sheet2) holds the numeric equivalent of that grade, i.e A = 1, B = 2 etc.
The rows in (sheet2) hold information on the target grade and the current performed grade, as picked up from the concat where the assessment period is either 'Target Grades' OR 'Autumn End of Term'.
What I am looking to do is to have the grade in my original cell in (sheet1) to have conditional formatting applied based on if the numeric equivalent of the end of term grades in (sheet2) is <, = or > the target grades.
Im not sure if this is possible and have found some other helpful posts such as this one;
Multi-column vlookup conditional formatting
But my issue is that I have 000's of records so would be very time consuming and data heavy to have a conditional format for each and every record such as proposed;
=IF(sheet2!M12<ODBC!M4,"RED",IF(sheet2!M12=ODBC!M4,"YELLOW",IF(sheet2!M12>ODBC!M4,"GREEN")))
What is needed is to incorporate the VLookup so that this can be calculated all at once and basically smash these two functions together;
=AA15 < vlookup(CONCATENATE($B$4,AA$12,$A15)ODBC!$F:$M,8,FALSE)
=(ODBC!$F:M,8,FALSE)<(ODBC!$F:M,8,FALSE)
Please see the below images FYR
Sheet1;
Sheet2;
I'm not even sure if this is possible and is well beyond the scope of my Excel experience so any help would be very appreciated!
EDIT
I have tried this Formulae for the Green colour;
=VLOOKUP(CONCATENATE($A$2,E$5,$A8),Sheet2!$F:M,8,FALSE)<VLOOKUP(CONCATENATE($B$4,G$5,$A8),Sheet2!$F:M,8,FALSE)
This works but for some reason, when applied to other sections with the same added but with a '>' or '=' for red or orange it seems to break and not format properly.
Any Ideas?
I Have fixed this!
After much looking around it seems as though I was on the right track with the EDITs formulae;
=VLOOKUP(CONCATENATE($A$2,E$12,$A1),ODBC!$F:$M,8,FALSE)>VLOOKUP(CONCATENATE($A$4,E$12,$A1),ODBC!$F:$M,8,FALSE)
After coming back to this after a few days, the formulae seemed to work and I was able to successfully spread across the whole sheet, saving me countless hours of individual formatting! Not sure why this was not working originally, it may have had something to do with my cell selection within the "Use a formula to decide which cells to format"!

Conditional Format in Excel when adjacent cells are equal

I have numbers stored in cells D5:S19. Each row of this array represents a specific product, the number in each column represents the cost of this item in a given financial quarter (if the product is not available in a given quarter then the cell is blank):
I'm struggling with setting up a conditional format which will highlight the cells which are adjacent and equal on a row by row basis (excluding the blank cells). I have tried using a formula based around the EXACT function (EXACT($D5,$E5)) for the entire array but this doesn't seem to work at all.
Any pointers here would be greatly appreciated. Thank you.
The way I see it, your highlighted data is going to be in one of three states. It is either:
The first entry of several consecutive entries
The last entry of several consecutive entries
Somewhere in the middle.
This lends itself to three distinct conditional formatting rules, to make sure that the use can distinguish between different sets of consecutive values. These come through as follows:
Notice the borders specified for each rule. We then order the rules in reverse order, and set rule 3 to "Stop if True". This means that left and right borders aren't added to our middle cells, like so:
This results in the following conditional formatting (I have only used a subset of your data)
Here's a text version of each of the rules for you to copy:
=AND(D5<>"",D5=E5)
=AND(D5<>"",D5=C5)
=AND(D5<>"",D5=E5,D5=C5)
Hope this helps!

Resources