VBA on conditionally formatted cell - vba

I'm trying to calculate a cell base on a cell which is conditionally formatted.
I've use IF statement to calculate the price per box if the ICO (ICO is our term for average order per 3 months) is Conditionally formatted (I use gray color and bold it to diplay that it is in Case and not per piece) , if it's not bold the cell must calculate the price per piece. I've tried using the VBA that returns the value True or False if the selected cell is conditionally formatted even if the condition is not met. You have any idea how to display true or false if the condition is met by the cell?

Related

Conditional formatting based on formula addressing current row in LibreOffice Calc

I have a column of cells in LibreOffice Calc with conditional formatting to apply a style to those cells.
The conditional formatting is programmed to format the cell if the following formula is true:
AND(B106=0,C106=0)
The trick is that instead of always evaluating this formula for row #106, I would like to evaluate the formula for the current row.
For example, in cell A1, I would like the conditional formula to be
AND(B1=0,C1=0)
And in cell A2, I would like the conditional formula to be
AND(B2=0,C2=0)
What I'm looking for is to program the entire column with a conditional formula like
AND(BCURRENTROW()=0,CCURRENTROW()=0)
but obviously that syntax is incorrect.
How can I accomplish this?
A conditional formatting based on a formula has two settings that determines where and how it applies.
First is the Cell Range to which it applies to. If this is
Range : A1:A1048576
then it applies to the whole column A.
Second is the formula itself. Precisely whether cell ranges in that formula are relative or absolute or mixed. As in all other formulas, a relative cell reference is A1 for example. A absolute cell reference is $A$1 for example. And mixed cell references could be $A1, where column A is absolute but row is relative, or A$1, where column is relative but row 1 is absolute.
So a conditional formatting applied to range A1:A1048576 and having formula AND($B1=0,$C1=0) should fulfilling your requirement. As you see the formula always gets columns B and C (absolute) but gets the row in which it is actually calculated (relative).
Example:
If you want to paint all row with a color when the column "B" CONTAINS a value, for example "XXX" you can do this:
Format-> Conditional Formatting (Add)
We select "formula" and we put:
SEARCH("XXX";$B2)>=0
We apply the style "Good" (To view selected rows in green)
And we select the matrix in we want actuate (important!), by example :
A2:H109
Now we see all the rows where the column B contains "XXX" in green.
enjoy !

Change the color of x number of cells based on the numeric value from another cell (in multiple rows)

My question is basically the same as this one (Change the color of x number of cells based on the numeric value from another cell) with one extra condition: for multiple rows.
enter image description here
So on the left side, there's a column "PTO 2018 Total" (range= I3:I80) and I want to color each row (range= J3:S80) based on the number of the column I, like I manually did for the first two rows.
Thank you so much in advance.
Use conditional formatting:
Use a formula rule with the formula:
=AND(COLUMNS($J1:J1)<=$I1,ISNUMBER($I1))
Applied to
=$J:$S

Color Grid in Excel by vb.NET

I need some help.
What I need is a code for colorid the Grid in Excel in this way:
find the first cell with value ( 1 )
find the last cell with value ( 2 )
range (1:2)
Color the grid black
My code by now:
'Color the columns A to K and ALL the rows below, no matter if they have a value or not.
xlWorkSheet.Range(xlWorkSheet.Cells(1, 1), xlWorkSheet.Cells(xlWorkSheet.Rows.Count, 11)).Borders.ColorIndex = 0
I need to change the color of not-empty rows .
THX
Find the first cell :
You should active the first cell (A1) and use IsEmpty function.
Then you loop in the same column until you find a cell containing a value.
By the way, you need to keep the number of this row for the second point.
Find the last cell :
You have to exit your loop when it finds a new empty row. Then you'll get the range of cells using the number of first and last row.
You can check the MSDN - "Empty Cells" to get more details.

Can't evaluate Conditional Formatting of COUNTIF function

I'm having problems checking if my conditional formatting equates to true in VBA. Formatting works correctly on the spreadsheet and changes the cell colours but VBA is showing no conditioning is applied when the COUNTIF function is used.
On each cell within a range I have set up three conditions:
1: =WEEKDAY(DATE($B$4,$A$5,$C$4),2)>5 - Changes colour if the day is a weekend (light blue)
2: =COUNTIF($AL:$AL,DATE($B$4,$A$5,$C$4))>0 - Checks a range (AL column) to see if the date appears in it (dark blue)
3: =COUNTIF($AM:$AM,DATE($B$4,$A$5,$C$4))>0 - Same as above but checks a different column (yellow)
Its a holiday spreadsheet. Column AL holds any public holidays that are set and column AM holds holidays that the company sets. The calendar then highlights the grid with weekends and holidays
B4 - Year
A5 - Month
C4 - Date
A5 & C4 addresses change depending what cell is selected however I have had to use absolute addresses as evaluate doesn't work with relative addresses.
In my VBA code I need to check if a condition has been applied and put a value of "P" for public hols or "Z" for company hols. When running the VBA however it does not recognise that these conditions have been met.
Condition 1 is picked up on as TRUE but it does not see when the other 2 conditions have been met even though the colours have changed on the sheet?
I tried taking out the DATE within the COUNTIF and hardcoding a string but still didn't pick it up in VBA so it's not that.
To return the active condition in VBA I am using:
For Ndx = 1 To Rng.FormatConditions.Count
Set FC = Rng.FormatConditions(Ndx)
If Application.Evaluate(FC.Formula1) Then
ActiveCondition = Ndx
Exit Function
End If
Next Ndx

SSRS 2005: Dynamic Background Color for Cells, Excluding Subtotal Cells

I have an expression in place in my report to change the cell color if the value of the cell is above a certain threshold. It's just an expression setup in my text box called "percent" - on the background color property. Looks like this:
=IIf((FormatPercent(Sum(Fields!items.Value)/First(Fields!totalItems.Value),2) >= .04 & "%"
And First(Fields!errorCodeAdjType.Value) = "Error1")
Or (FormatPercent(Sum(Fields!items.Value)/First(Fields!totalItems.Value),2) >= .02 & "%"
And First(Fields!errorCodeAdjType.Value) = "Error2")
,
"Maroon", "Transparent")
It works as I want it to; however, it is also changing color of my subtotal cells. How can i write this better to make sure it doesn't think that one of my subtotal cells meets the cell color criteria? Thanks!
You can set the background property individually for different cells. Sounds like you've defined this for multiple cells. Clear the BackgroundColor property for the cells that are in the subtotal row.
If you don't have a separate subtotal row defined in the report, then you'll need to add a condition that can distinguish subtotal rows from detail rows. I strongly recommend that you create the subtotals by using SSRS groups, not as subtotal rows included in the query. That is, avoid WITH ROLLUP.