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.
Related
How to change one cell fill color based on the text of the previous cell.
I know that I need to use conditional formatting along with using a formula to determine which cell to format, but I just can't figure out what formula to use.
Depends on the condition, you can use Conditional Formatting on the Home Tab and set a rule
under Use a formula to determine which cells to format there you can specify if for example =A1>5 Format it to Fill Green then select to what cells you want this rule to be applied.
You can find more information here: How to create rules with Conditional Formatting.
How can I get formula applied behind conditional Formatting for highlighting Cells?
Conditional Formatting is applied based on text in each cell of Test Result column(third column).
Formulas List:
Purpose is to reuse (copy paste) the formula in other sheets.
The formula is shown in your first screenshot. The dialog has the formula in the column "Rule applied (in order shown)". These rules use the out of the box settings to format cells based on their values, so the "formula" is not accessible for editing.
But the format can be copied to other cells very easily.
Here are the steps:
Select the cell with the conditional format and copy it
click the cell where you want to apply the same format
use Paste Special > Format to paste just the format to the selected cell
Edit: If you don't use the built-in conditional formats but instead select "Use a formula to determine ...", you can construct the formulas manually.
There is no automated way to convert the existing out-of-the-box rules to fomulas. You will need to use your human understanding of the logic and appy this to formulas. So, for example, if the selected cell is H3, you can us this formula
=H3="Fail"
and format the cell with red font and light red background. Note that there are no $ signs in the reference to the cell H3. If you copy that format to another cell, it will apply to that other current cell.
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
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.
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.