Hello
This is about appling conditional format to a excel workbook.
I need this in VBA (only VBA) module in excel that will execute when opening and/or with a button.
It will run in excel 2003/2003.
Very easy to do, just read carefully, you will need 4 if clauses to do this.
ONLY VBA!!
Steps
you have to apply this format starting in column A and going rigth (stop in the last column wit data). Now it is the column “CD”, but this can change, so search fotr a null value in row “3″.
Also apply it from row 4 to the last row with data (this will be when you find a null value in column A”). The number of rows will change, so you need to search for the first null value.
If column “L” has the value “Real”, then apply the coluor you see in exsample (gray). Apply this gray colour but only from column “A” and stoping in the last cell that has a value. See example, it must look like the excel file. Do not consider the column with the tittle “total dias”.
Important: the number of column may change, so you must identify it by the label.
After this, look column “A”, there you will have the id of the “obra”. For each “obra” you will have 2 rows. The first is the schedulle (in column “f” the value is “previsto”) and the second is the “final data” (the value in column “L” is “Real”). We need you to compare the value “real” and “previsto”. So, for each “obra”, read the columns with the label “fecha inicio” and compare the value in the row “real” with the value in the row “previsto”.
For each cell move up to find the value you have to compare with
if “real” >= (“previsto” +8) /// apply the red colour
if “real” is null and, “previsto”< now() // apply the red colour
Do the same but for the columns with the label “fecha fin”
Finally, if “real” <= “previsto apply the green colour (for both “fecha inicio” and fecha fin”)
Remember, the number of columns may change, you will read up to the last column with value.
There are a couple of wexample of the colour in the sheet.
Thanks