Another Question about Microsoft Excel

Let’s say I have a column of number that I’d like to Autosum. Ok, cool Excel has a feature to do that already built in.

Now lets say I’d like to get a sub total out of that column. I want to get the total of all values that are bold (or red, or whatever). Can I do that without actually going and manually picking the fields that are differently styled?

I don’t know of an easy way to do this. I searched for “sum color” (without the quotes) on this message board and it turned up a couple of threads on this question but doing it involves some VBA code that I don’t understand how to use.

Hilight a cell where you want the sub-total, click on the autosum icon, then click on the cells you want to add, using the control key if they aren’t adjacent. Hit enter and there you go.

Yes, I understand I can find my subtotal that way. However, If I have 2,000 line items to go through, this can be somewhat tedious. I was looking for a way that I could tell excel to just subtotal everything in a column that was styled differently.

What is the criteria that makes you highlight the numbers red? There is a SUMIF function in Excel that will sum a long column of data, but only includes a data point if it passes a user-defined logical test. Unfortunately, I’m not sure how to set up a test to determine font color (or if the font is bolded or not).

the values are formatted arbitrarily.

If they’re formatted arbitrarily, then why do you care what they subtotal to? That subtotal would have no significance.

Now, if you had some sort of reason to bold certain values and not others, then you should logically group those types of values together, providing for an easy subtotal. But since you say it’s arbitrary, why even bother?

You’ll need a macro to do it. Here’s a short section of code from a macro to shows how you’d do it (assuming the cells you’re interested in are in column C, rows 1 thru 100).

colortolookfor = 50
sum = 0
For i = 1 To 100
    Range("C" + Trim(Str(i))).Select
    if Selection.Font.ColorIndex = colortolookfor then
       sum = sum + selection.value
    End If
Next i