QUESTION: I have cell values in a column with different font colors, which have been determined by conditional formatting. However when i attempt to total the values by font color using a macro, it will not recognize the new font color. Can you help please ?
VBA can not see the font color (or cell color) produced by conditional formatting. The best way is to sum using the condition that the conditional formatting uses to determine the color.
Sorry - but that is the way it is.
---------- FOLLOW-UP ----------
QUESTION: Not sure how to do that, given that there are values with different font color also in the column
If you have some cells that have a red font color manually set and you have some cells that have a red font color based on conditional formatting with a rule of =A1>5 in the range from A1 to A100 then you could loop through them
note: the rule =A1>5 is the relative formula for cell A1.
tot = 0
for each cell in Range("A1:A100")
if cell.font.colorindex = 3 or cell.value > 5 and isnumeric(cell) then
tot = tot + cell.value
Msgbox "Sum of red font cells is :" & tot
Hopefully that illustrates what I am talking about.
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here