"Static" can be a technical term in VBA, but I was using it informally; I meant that the size and location of your ranges will be the same for weeks or months at a time. When I write an Excel program, usually before it can get down to work it has to identify the rows I want to process, for example by finding out which rows have "Total:" in column A, or by looking in a column for a change from one area code changes from one to the next. In your case, if I understand you, you don't have to do that—you can count on processing the same set of rows—they remain "static", in other words, without changing. Oh, they might change at some point, but seldom enough that if they do you can just go into your program and change the code. The opposite of "static" in this sense would be "dynamic", which would mean the they change a lot.
Now about your idea for working with just one range instead of a bunch: What I thought was happening (but I knew I might be wrong) is that you had some specific ranges that you wanted to color according to column C in the first row of each range. (That's why I talked in the subroutine about "C1".) But from your new proposal, it sounds like what you may want to do is color each row—each row in the whole range—based on a value in that one row. Is that right?
Like this: look at L1 and color that whole row based on whether L1 contains "Phase" or "Sub-Phase". Then color row 2 based on the contents of L2, and row 3 based on L3, and so on down to the end.
Is that right? If so it makes the job simpler—but if I'm wrong, we can still do it. I just have to be sure I understand what you need to accomplish.
That's very often the longest part of the job, by the way.
Also by the way, another time if you have to ask a question like this, it may save some time, yours as well as mine, if you post an actual workbook with either real or sample data, and a demonstration of the result that you want.
|