Conditional Formatting rows with shared Merged Cell - excel

I've got a little helper spreadsheet that I use, and there are some Merged Cells.
Rather than get rid of these, which I know can cause headaches, I was looking for an idea on fixing an issue.
I have a few rows that share a merged cell. When this merged cell is not empty, I want the rows to highlight. Currently, the formula (applied over A1:B4) is =$B1<>"" and then a fill. Works okay for the first row, but not the other three:
I was thinking I could add some more logic, but there's nothing really there for me. It's a pretty simple table. Unfortunately, there's not really a way to say (for rows 2:4), if row 1 is colored, then color this row...(Although I think I've seen clever uses of Named Ranges to do something like that, but I could be mistaken).
So, in A2, what's the conditional format formula "thinking"? Is it going to =$B2<>"", in which case ...what's it looking for as B2? If I select A2, and look at the conditional format rule applied to the current selection, it still shows =$B1<>"".
Thanks for any ideas/tips. It's not a huge deal, so I don't need a VBA solution - just maybe an idea or trick for using CF with merged cells.
Edit: For a more full explanation - the idea is that col. B will have an invoice number and if it's there, make the row a color. I will be repeating this "chart" a bunch, and have some non-grouped companies, who have their own lines. I just don't like the gap of color there in my group and was trying to get it to have a color when the first of the group does.

I usually try to base my CFR's on formulas.
    
After selecting all of column A and B I created a CF rule with the following.
=AND(LEN($A1), ISNUMBER(MATCH(1E+99, $B$1:$B1)))
The approximate MATCH function simply looks for the last number in the B column. I can see a missing invoice number in a cell like B7 would generate confusion but perhaps you can expand on this for conditions not demonstrated by your examples.

If you want to use "placeholder" instead of blank cells (when there is no invoice), you could try the following formula:
=(LOOKUP(2,1/($B$1:$B1<>""),$B$1:$B1)<>"x")*LEN(A1)
With sample data it looks like this:
When the cell is left blank (no placeholder), column A is highlighted, column B is not.

Related

how do I compare each row of two different columns and highlight the highest value (not formula) in each row?

I have two columns to compare. All cell values come from the ROUNDUP function. =ROUNDUP(C6/D12,0) etc.
I want the larger, or equal, of the two in each row to be green and the smaller red. Using the formula, it does not work as expected. If I do the same with numbers typed, not the formula, it works. It appears the formatting applies to the formula and not the value.
That is the first half of the problem. I also want to autofill/paint the conditional formatting to numerous cells, but it always compares to the top left cell, rather than the two cells on the same row.
If I use the color scales formatting it works, but I do not want the scales, just red/green.
It seems hard to believe that what I want to do is not possible. Can someone please help me with this. Thanks in advance.
In conditional formatting, under 'use a formula to determine which cells to format', you need to enter
=A2=MAX($A2,$B2)
to highlight the larger cell and (as a separate rule)
=A2=MIN($A2,$B2)
to highlight the smaller cell.
Note that in the case where both cells have the same value, they will both be either coloured red or green depending on the precedence of the rules. If the 'green' rule comes first,
it will look like this:
Conditional formatting is almost its own little science within Excel. It may be more useful to find youtube tutorials on the topic than depend on a text explanation here. But the central theme is this.
You will use location locking (the dollar sign or F4) in front of the letters so that any cell to which the format is applied knows you specifically mean columns E and F, for instance.
Example: Assume your first row goes from A5 to M5, and the condition values are in E5 and F5.
I find it easiest to format one row with the rules I want, test them, and then use the format painter or copy -> paste format along with careful use of $ locking.
Drag over and select the entire row of cells A5:M5
Conditional Formatting -> New Rule -> Use a formula to determine which cells to format
In the formula field enter =$E5>$F5. Excel gets weird and often inserts double quotes. If you save the rule and go back in, it may say ="$E5>$F5" and if so delete the double quotes.
Click Format and create the cell format you want.
With A5:M5 still selected, add another rule and format for ="$E5<$F5"
The $ sign works the same way as it does in a formula. All of the columns get their format based on columns E and F, but all of the rows base their formula on the E and F values in that same row.

Excel Dynamic Conditional formatting

I am sure this is really simple but cannot get it to work. I am trying to do some conditional formatting on a sheet that over time will have additional columns added to it. I want the formatting to be there before hand since the data is being added via VBA and the person using the spreadsheet are not Excel experts.
What I have is a column with numbers in. When a new column is entered I want to compare the value with the value in the previous column and then colour the cell accordingly. I can do this for a single cell with for example "=D2>C2".
I want to be able to write the rules in cell D2 comparing it with cell C2 and then have the rules apply across the area D2:DDD300. So for example cell N19 will compare itself to cell M19.
I thought I could use the "Applies to" box but that does not work. Any ideas on how I can achieve this?
Okay this now appears to be working. Not sure what I did differently but deleted all the rules and then set them up again. The only thing I did different was to initially do it for just the 1 cell, then expanded it out to the row when I knew it was working, then finally the whole area.
Sorry to have wasted peoples time
Your method should work. It does for me. Maybe this helps:

Conditional formatting of two rows in Excel through row comparison

Consider the following data:
I would like to compare each cell in row 1 to the adjacent cell below in row 2, using red for inequality and green for equality. A similar principle applies for rows 3 and 4. I.e., the output should be
The data I have in reality have more rows and columns than in this toy example, so the less manual work that has to be done, the better. The data I have are small enough that I would be fine pointing and clicking for results. I've tried using Conditional Formatting for this, but haven't been able to figure out its formulas.
I would prefer a non-VBA solution if possible.
I don't necessarily need the provided solution to be general, as long as it's clear to me how it can be generalized. I.e., it needs to be obvious how to adjust the solution when the data start at a different row or column, other than cell A1.
The following formula will format all pairs of nonequal cells:
=OFFSET(A1,1-2*MOD(ROW()+1,2),0)<>A1
Create a second rule with <> replaced with = to format the equal cells.
Fill all the cells red then use this rule to turn them Green
=AND(A1<>"",OR(AND(MOD(ROW(A1)-1,2)=0,A1=A2),AND(MOD(ROW(A1)-1,2)=1,A1=INDEX(A:A,ROW(A1)-1))))

How to set the background of three cells based off of the value in one other cell, relatively?

I'm trying to make a formula that will color code three cells that are directly above/below each other. The color coding depends on the sum of three other cells that are directly above/below each other, and directly across from the cells to be colored.
This part is easy. The rule is:
Forumula: =SUM(H5:H7)>30
And it applies to:
$E$5:$E$7
However, the issue is that when I copy the cells that are being colored (E's) to three more cells below them for the next batch, the relative formula does not work as expected. It applies the formula on H6:H8 (+1) instead of H8:H10 (+3).
Is there a way to get the relativeformula to work as expected? I hope this was clear enough. I know it's hard to visual a spreadsheet, but ultimately I need the relative forumla to add +3 instead of +1 when it is copied.
Problem:
If I correctly understand, what you are trying to achieve is to have the range E5:E7 formatted strictly based upon H5:H7, then the next three-cell range - E8:E10 - based upon H8:H10 and so on. You can do this by implementing the below solution:
Solution:
Step 1: Setup Columns as Below
Step 2: Implement Conditional Formatting as Below
Explanation:
I have recreated your issue and I see your problem; it was not that obvious until I played around with changing values of different cells in Column H.
Apparently, this has to do with how Excel interprets your instructions (formula) supplied under conditional formatting. To understand this let's first focus on the behavior of cells E5, E6 and E7 as a function of values in Column H.
With the formula =SUM(H5:H7)>30 did you notice that:
E5 format depends upon =SUM(H5:H7),
E6 format depends upon =SUM(H6:H8), and
E7 format depends upon =SUM(H7:H9) and
when you copy the range E5:E7 three cells down into E8:E10, the expected behavior is:
E8 format depends upon =SUM(H8:H10),
E9 format depends upon =SUM(H9:H11), and
E10 format depends upon =SUM(H10:H12)
And this is exactly how the range E8:E10 will behave once the above solution is applied.
A partial answer to your question has to do with your relative formula - =SUM(H5:H7) - under conditional formatting. Using this formula causes $E$5 to use =SUM(H5:H7) to determine its formatting, $E$6 to use =SUM(H6:H8) to determine its formatting, and so on. This ultimately leads to issues with the conditional formatting even before you begin copying the cells down.
EDIT: (piggy-backing off #Bharat Anand's answer)
#Bharat Anand's answer appears to be the best way to accomplish this question.
#Thisisstackoverflow requested clarification (under the accepted answer) and I'm hoping my screenshot below will help.
I set my worksheet up in what I believe is the exact same manner as #Bharat Anand, and it seems that the column letters may have been off. Setting mine up like this made it work correctly.
EDIT: (clarification for future visitors)
I really liked #Bharat Anand's solution, so I wanted to explain how it works (using the images/formulas in the solution as reference):
The calculation in Column I is setup to return a number that will only appear three times, in succession, in Column I; in this way it kind of behaves like a unique identifier, allowing other formulas to reference these values for calculation purposes.
Three times is key for the original poster because they were looking for a range of three cells to be formatted based on a sum of three cells. For example, the formula in Column I can be modified to
=ROUNDDOWN((ROW()-b)/a,0)
where:
a is your desired number of cells to format/sum, and
b is equal to a - 1.
Using the formula in J5 as an example, this SUMIF formula uses I3:I7, which includes two (or b, as setup in my explanation above) rows above and two (b) rows below to decide if I5 equals any of the values found in I3:I7. It's important to include the two rows above and two rows below so that the range overlaps the same three cells to meet the requested requirements.
When I5 finds a match, the formula looks to Column H to sum those rows in H3:H7 where I3:I7 equals I5. In this example, J5, J6, and J7 will each equal 32.
Using the simple conditional formatting formula that was setup, we know that cells in Column E should be highlighted when the corresponding row in Column H is greater than 30. According to the original question, this should be done in ranges that are three (a) rows tall. We already handled for that, so all that was left was to make sure the conditional formatting spanned the data area in Column E.
I'm hoping I don't confuse and/offend anyone with this explanation, but it's how I understand it. I like the proposed solution and explaining it to myself again helps me solidify how it works.

Copying cells from one worksheet to another if a column matches a value

I'm trying to use formula to copy data from one worksheet to another where a column matches a certain value.
To be more specific, I want Working!A2:E100 to contain Data!A2:E100 but only for those rows where Data!C2:100 contains the value "Fixed".
Doing this with leaving blank rows is simple, I just create the formula:
=IF(Data!$C2="Fixed", Data!A2, "")
And copy that formula across all the cells.
But then I thought I'd get clever and have it not copy across blank lines, and entered a maze of unclear excel tutorials and vague error messages.
I've created this formula:
=INDEX(Data!A2:Data!A200, MATCH("Fixed", Data!$C$1:Data!$C$200, 0))
And entered it as an array formula using ctrl shift enter.
However all I get is the contents of Data!A2 repeated over and over in every cell of my spreadsheet.
Does anyone need to know what I need to do to make this work?
This is my attempt at a local prototype following the example in BruceWayne's answer, the results are visible:
As you can see "Row 2" just appears repeatedly in the result column. Excel doesn't seem to have an easy way to see what version it is any more but this seems to be a pretty recent one, it's got the ribbon with the file menu and all menu headings are capitalized.
Here's a formula you can use (note: enter this as an array):
=IFERROR(INDEX(A$1:A$200,SMALL(IF(C$1:C$200="Fixed",ROW(A$1:A$200)-ROW(A$1)+1),ROWS(A$1:A1))),"")
You may need to tweak the ranges, I think I got them to match yours, but again, probably need to tweak. You can then drag this down, and it'll fill in with the values from column A, skipping any blanks.
Edit: Here's a screenshot to (hopefully) help show what I did:
You can edit the ranges, naturally, to be over two sheets.
To clarify, A$1:A$200 is the range of what you want to return (the index). C$1:C$200 is the range that holds "Fixed".

Resources