How to break the chains of POOR CONDITIONAL FORMATTING options in EXCEL? - excel

use the following function to create an invoice.
=VSTACK(FILTER(PerformedTestsTable9,PerformedTestsTable9[Qty]>0,), {"","","Total sum to be paid:"})
Very simple, filtered table for Qty > 1 plus added row with VSTACK.
I use conditional formatting rules to format every other row, blank cells and the last row.
However every time I change something in the source table I get "Total sum to be paid:" left aligned in the bottom right cell. If I right align it manually it does not spill into adjacent left cell because it is not blank.
I can not add the borders I want, I can not change the font, I can not change the size of the font.
What I want is something like this:
Is there a way to achieve those results, even partially, without resorting to programming.
In pseudo-code
On Calculate
Turn off Manual Calculation
Unmerge cells that cause SPILL error in FILTER function
Reset formatting in the spill range of filter function to baseline
Calculate filter function
Identify bottom row and merge cells, right align merged cells, choose bigger font, add borders

Related

How to highlight four random selections from a column?

I'm trying to randomly highlight (change the cell colour) of four cells in the first Excel column. It is important the selections highlighted are only cells containing data as the size of the data set will vary.
The highlighted selections needs to be un-highlighted when the macro is run again to generate four new selections.
I have tried to brute force this with functions (RAND-RANK-XLOOKUP), but the outcome is messy and doesn't react to different sizes of data.
Highlighting the cells in a color is the goal, conditional formatting could be suitable.
Four random cells from the first column of the Excel sheet is the target (cells only containing data).
Using Conditional Formatting
Let's say you have data in column A. For example 16 rows like this:
You could use the COUNT() function to calculate the number of cells with content in column A in cell D1 :
=COUNT(A:A)
And then you could calculate the position of the cells you want to highlight with
=RANDBETWEEN(1,$D$1)
Then you can create a helper column to check if a cell should be highlighted.
Formula in G2 : =IFERROR(MATCH(CELL("row",A2)-1,$D$2:$D$5,0)>0,FALSE)
The idea behind this function is simply to check if the row of the data point corresponds with one of the random positions we have.
Finally, you would use a formula to define your conditional formatting by applying it to Column A and using =$G2 as the formula.
Note that:
The highlighing will reset everytime you change a cell provided that you have "Automatic calculations" turned ON.
There is a possibility that 2 or more of the random positions are the same, so you'll need to recalculate if that's an issue.

Add border to cells in a table if another row is added in excel

I have an Excel spreadsheet which spans columns A to T and for ease of reading, the cells have borders. Currently when another row of data is added to the spreadsheet though, I, or other users, have to add borders around the cells, just for cells in columns A to T where is something (usually, but not always, a date) in Column B on that row. The spreadsheet is a log of survey results, and gets very long by the end of the year, but doesn't have a defined number of rows, because it's being added to all the time. It's not much of a problem for me to add borders, but other users not familiar with Excel either manage to add borders to all the cells in columns A to T making the end of the list look untidy with cells with borders but no contents or they just don't bother adding borders and it gets very messy for managers to read (apparently!).
I'm trying to use conditional formatting with a formula to format the cells, but can't seem to get the formula right. I'm basically trying to get Excel to add a border around cells in columns A to T on any row where the cell in column B on that row isn't empty. I've tried various formulas with no luck so far and just end up with borders everywhere but where I want them!
Some of what I've tried so far (I can't remember all the ones that didn't work!):
(row 4 is the first row of data)
=$B2<>"" (applied to =$A:$T) (adds borders above the table, but not below)
NOT(ISBLANK($B4)) (applied to =$A:$T) (doesn't add any additional borders)
=B4<>"" (applied to =$A:$T) (doesn't add any additional borders)
=not(exact(B4, "")) (applied to =$A:$T) (doesn't add any additional borders)
...and of course using Excel's inbuilt "cell doesn't contain a blank value" doesn't allow you to specify that you want to know if another cell isn't blank. It'll add borders around cells after you've input into them, but if a cell in another column is blank for any reason, it leaves 'holes' in the table where there aren't any borders which makes it look even more messy.
Am I just fundamentally misunderstanding the formulas, or can this not be done? (or do I need VBA to do this?)
Your formula needs to refer to the first row of the Applied To area:
=$B1<>""
And apply it to =$A:$T

Excel Help: Applying Conditional Formatting to Numbers in Percentage format

I am currently trying to apply conditional formatting to certain rows which contain numbers in percentage (e.g. F11 to N11; F14 to N14; F17 to N17 and so on). These are also the only rows in the worksheet that have numbers in percentage. Would like to know what the fastest way to go about doing this is.
Should I:
(i) apply conditional formatting to the whole worksheet to numbers in percentage (if possible) or
(ii) apply conditional formatting to each individual row which is extremely time-consuming?
Appreciate if anyone can help.
Thanks in advance! :)
If your data in the percentage rows is also formatted as percentage, you can use the =CELL("format",[reference]) function, that returns "P0" or "P2" for percentage formatting.
Use a helper column (which you can hide if you want) to check the formatting of the first/last cell in the row, and then set conditional formatting based on the column:
After you create the column, you set a conditional formatting rule on the the upper-left cell in the range based on the formula: =[top cell in helper column]="P0". Keep the column fixed with a $ but not the row, as in the screenshot below, so you can drag the formatting to all the range with correct reference to the helper column.
Next step is to drag this cell to all the range, choosing the "formatting only" option:
Finally, you have to format again all rows that contains percentage values to percentage formatting.
However, if the place of the percentage rows is fixed, you don't need that CELL() function, just write in the helper column something like p or 1 for the rows to format.
(I have also tried to plug the formula directly to the formatting condition, but it doesn't work well all the time)
Tell me if it solved your problem ;)

Format cell fill based on a range of values

Could anyone advise how to format the fill of cell based on percentile ranges? So for example, I have a row of values. I'd like to format the fill on those cells such that I have cell fill colour for three conditions: above the 90th, between 10th and 90th and below the 10th percentile. If I try to create a conditional formatting rule with a 3-color scale, I am not sure how to format the 10th to 90th percentile range.
So basically what I am asking is how to format a row of cells thresholding on a range.
Thanks in advance!
Using Excel 2013, might be slightly different path for older versions.
Highlight the cell range you want.
Home -> Conditional Formatting -> New Rule
Under New Rule, there should be 6 options, choose option Format only top or bottom ranked values. Choose Top, 10 (or whatever number you want), and click the box for % of the selected range.
Hit Format and go to Fill, and choose a background color.
Do the same thing, but now choose Bottom instead of Top.
This will highlight the top x% and bottom y%. Also, if you're open, you should also try Icon Sets and you can use Green/Yellow/Red circles or arrows to help.

Excel Conditional Formatting 3-color over one row applied to many rows

I've got some excel spreadsheets with a couple hundred to couple thousand rows. Each row represents a set of measurements taken at one second intervals.
I want to use the 3 color conditional formatting for each row. I can setup a single row for the 3 color by setting the "Applies to" to something like:
'Table1'!$B$2:$M$2
However, if i try to copy the format and then apply it to multiple rows, (say B3:M400), it will treat the entire block (all cells from B3 through M400) as a single conditional format, so each cell is colored according to all of the other cells. What i'm looking for is a way to apply the 3 color conditional formatting to each row individually over many many rows.
For example, in the image linked here: http://electriceptor.files.wordpress.com/2012/04/screen-shot-2012-04-30-at-11-53-36-pm.png (sorry, i'm too new to post images), each of the rows has an individual 3 color format that i manually applied to each row.
However, if i copy a single row and paste the format into that same block of 7 rows, it looks like this image: http://electriceptor.files.wordpress.com/2012/04/screen-shot-2012-04-30-at-11-56-42-pm.png:
Note how the formatting is applied to the entire block.
Is there a way to apply the conditional formatting for each row individually without doing each row manually?
Since 3-color conditional formatting doesn't accept relative references (no matter how much you try to 'trick' Excel with INDIRECT, ADDRESS, etc.), your best bet is to use the method here (example was for 2-color formatting): https://superuser.com/questions/350378/excel-2007-conditional-formatting-so-that-each-row-shows-low-values-yellow-hig
This is the same as using the format painter on each individual row (using the format painter on multiple rows puts you back to square one where it looks at all the rows).
Sub NewCF()
Range("B1:M1").Copy
For Each r In Selection.Rows
r.PasteSpecial (xlPasteFormats)
Next r
Application.CutCopyMode = False
End Sub
Also, there's no limit to the number of conditional formatting rules (at least in Excel 2010), but the more you have, the more potential there is for a negative impact on performance. You'll just have to try it and see. In the worst-case scenario, I would make 3-10 (or however many you can stand to make) individual rules based on a formula to create a "gradient", but this may be just as cpu-intensive.
I've just tried using the fill handle on a cell with conditional formatting e.g. =COUNTIF(C2,"Yes")=1 then applies to $A2 and then selected that cell and dragged the fill handle - it adds the conditional formatting to each row automatically! jippee!

Resources