Excel: stop cells formatting being applied to adjacent cell? - excel

I noticed that if I format (font, color, etc.) a certain number of cells in a row or in a column, as soon as I type text in adjacent cells in the same row or column formatting is automatically applied to the added cell. How can this automatic behavior be stopped? I'm formatting cells programmatically and style/color if often defined conditionally, it is not simply to please the eye or to make data more readable and excel's automatic formatting is setting formatting/color without knowledge of the underlying logic. Formatting is not being set via formulas but via C# code.

This is controlled by a setting of the Excel Application Object:
YourExcelObjectReference.Application.ExtendList = False

Related

Using the filling color of cell in conditional formatting rules

I have some cells with some different filling colors.I want to do the following thing: I want to use those colors in conditional formatting rules, so when I change the color of a cell, the conditional formatting color will change too.
Like in this image
In the screenshot above, there is a zone called "Legendă". So when I change the color of a cell there, the others cells with the same color will change too. The other cells have conditional formatting rule.
In general, formatting is not considered source data in Excel. The workaround, then, is to put the information in a new column.
Say you were formatting column B and wanted those colors to modify formatting elsewhere. The idea is to create another column and add your data there, and then create a conditional formatting formula for column B (and any other columns) that refers to your new data. This way, you can get as many columns as you want to respond appropriately.

Apply conditional formatting to many rows

I have a data validation set up for a list to choose from (B7:B1000), only two words can be selected: PP or SW. I have figured out a conditional format to fill the row if PP is selected but I need to apply this to the whole spreadsheet. I am having to apply conditional formatting for every row and it's time consuming if I need to do this for 1,000 rows.
I selected Use a formula to determine which cells to format. This is what I currently have it set up as:
=B7="PP" conditional formatting to be applied to =$F$7:$N$7
I now need to do this for all rows in the spreadsheet:
=B8="PP" conditional formatting to be applied to =$F$8:$N$8
=B9="PP" conditional formatting to be applied to =$F$9:$N$9
=B10="PP" conditional formatting to be applied to =$F$10:$N$10
and so on.
Is there a quicker way rather than manually doing this for 1,000 rows?
I have tried the format painter but its just copies the previous formula. Tried removing the $ symbols but when I click Apply they are re-inserted.
Your Title makes me wonder whether you would like some formatting for SW as well as PP but guessing you don't then in Row7 please try:
=$B7="PP"
for the CF formula and make sure Applies to shows =$A$7:$Z$1000 - or whatever column reference you choose in place of Z.

Conditional Formatting with Flexcel

I want to modify the colors of some cells in an already filled Excel spreadsheet using the method:
FlexCel.Adapter.XlsFile.SetCellFormat(int row1, int col1, int row2, int col2, int XF);
The colors are not always correctly displayed since the cells I modify are sometimes subject to Conditional Formatting rules that override background and foreground colors.
In Excel, there is a functionality to prevent a rule from being applied on a specific cell.
Is there such a functionality in Flexcel?
What is FlexCel? You may want to provide a link to this tool or describe what it does.
In general, direct cell formatting and conditional formatting are two different things.
You can apply a cell format (and I assume that FlexCel is an add-in that uses VBA to set the cell format) and the cell will show it.
Conditional formatting will override any direct cell formatting if the condition is met. It does not matter how the original cell format was arrived at. Whether or not the cell has been formatted manually or with a VBA routine or an add-in like FlexCel is insubstantial.
From the code snippet you posted it is apparent that the cell format is set with VBA. If a conditional format is applied to the cell, that will override the format applied by VBA.
If you don't want that, you will need to extend the VBA code to include/exclude your specific conditions instead of using conditional formats.

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!

Conditional Formatting in Excel using Alphanumerics

I have a conditional format in Excel that is displaying the up/down arrows based on certain values. This works just fine. However, in my spreadsheet (which is largely controlled by VBA) the user has the ability to review data in a 'grade' display (L=1,M=3,H=5) rather than the 1/3/5 score. I have a custom function that can convert the L/M/H to a number, but I can't figure out how to incorporate this into the conditional format. I can do it in a normal conditional format, but I want the up/down arrows icon set. I'd remove the conditional formatting and apply an icon to the cell with VBA but I don't think that's possible. Any help?
You could either:
Mimic Conditional Formatting
Forget conditional formatting and use excel 2003 type methods with arrows and Wingdings font. Looks very similar, Andy Pope has a good example:Mimic 2007 Conditional Formatting Icon
Use an invisible helper column
The hidden helper column will display the numeric values 1,3,5 based on the actual cells L,M,H. Then in the cell with the L,M,H, you add the conditional and set it to the value of the helper column.
What I ended up doing was adding an additional cell to the right that used a UDF to convert the cell values to numbers. I then applied the conditional formatting to this new cell and set it to to display the icon only. By locking the icon cell and protecting the worksheet (was going to protect anyways) the field is never user editable which is exactly what I wanted.

Resources