![]() |
CF based on data analysis, Loop thru sheet
I am trying to write code that applies conditional formatting when the date
in the active cell is a larger value than the date in a cell 2 columns to the left. I have users that enter these 2 dates, in a list of records, and I want all the text in each row to turn red when the above condition applies to the date values entered in that row. I want the conditional formatting code to evaluate every record in the list each time a change is made to the dates in these 2 columns. I have been trying to accomplish this with a Do While Loop, where I name the starting cell, evaluate the cell 2 columns to the left, Set the formatting if the condition is met, and move down to the next row, until encountering an empty cell. I am totally striking out here, and know my sytax is off, and my approach may also not be the appropriate one for what I am trying to accomplish. Any thoughts, or samlpes on how to compare 2 cell values in a row, apply formatting if the condition is met, and then check the rest of the records for the same condition?? (And update if the dates entered are changed?) |
CF based on data analysis, Loop thru sheet
You could use the built in conditional formatting under the format menu
without using any code. http://www.contextures.com/tiptech.html will give you some generalized insights. for code Sub ABC() Dim rng as Range, cell as Range set rng = Range(cells(2,"F"),Cells(rows.count,"F").End(xlup) ) rng.EntireRow.Interior.ColorIndex = xlNone for each cell in rng if cell.Value cell.offset(0,-2) then cell.EntireRow.Interior.colorIndex = 3 end if Next end sub Change the "F" to reflect the column that would contain the ActiveCell in your description. -- Regards, Tom Ogilvy "hspence" wrote: I am trying to write code that applies conditional formatting when the date in the active cell is a larger value than the date in a cell 2 columns to the left. I have users that enter these 2 dates, in a list of records, and I want all the text in each row to turn red when the above condition applies to the date values entered in that row. I want the conditional formatting code to evaluate every record in the list each time a change is made to the dates in these 2 columns. I have been trying to accomplish this with a Do While Loop, where I name the starting cell, evaluate the cell 2 columns to the left, Set the formatting if the condition is met, and move down to the next row, until encountering an empty cell. I am totally striking out here, and know my sytax is off, and my approach may also not be the appropriate one for what I am trying to accomplish. Any thoughts, or samlpes on how to compare 2 cell values in a row, apply formatting if the condition is met, and then check the rest of the records for the same condition?? (And update if the dates entered are changed?) |
All times are GMT +1. The time now is 12:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com