Counting cells based on cell formatting

Hello,

I have a large set of numerical data (cells I8:O24607) in which each
cell has been formatted to have either no fill or one of 5 different
colored (light yellow, yellow, orange, red, or black) fills. The cell
values and formatting were copied and pasted into this worksheet from
other worksheets so there is no conditional formatting applied to the
current sheet.

The formatting represents a quality rating and I would like to count
the number of cells that have either no fill or the light yellow fill
in each column. Is this possible to do using the IF function and
having the cell fill be the condition and the TRUE value be "1" then
summing the TRUE values? If so, how do I enter the cell fill as the
condition? Are there other ways to do this?

Thank you,

Andrea
0
krzystam (4)
10/15/2008 3:52:28 PM
excel 39879 articles. 2 followers. Follow

10 Replies
603 Views

Similar Articles

[PageSpeed] 59

See:

http://www.cpearson.com/excel/colors.aspx

-- 
Gary''s Student - gsnu200807


"amk1023" wrote:

> Hello,
> 
> I have a large set of numerical data (cells I8:O24607) in which each
> cell has been formatted to have either no fill or one of 5 different
> colored (light yellow, yellow, orange, red, or black) fills. The cell
> values and formatting were copied and pasted into this worksheet from
> other worksheets so there is no conditional formatting applied to the
> current sheet.
> 
> The formatting represents a quality rating and I would like to count
> the number of cells that have either no fill or the light yellow fill
> in each column. Is this possible to do using the IF function and
> having the cell fill be the condition and the TRUE value be "1" then
> summing the TRUE values? If so, how do I enter the cell fill as the
> condition? Are there other ways to do this?
> 
> Thank you,
> 
> Andrea
> 
0
GarysStudent (1572)
10/15/2008 4:44:12 PM
See http://www.xldynamic.com/source/xld.ColourCounter.html

-- 
__________________________________
HTH

Bob

"amk1023" <krzystam@gmail.com> wrote in message 
news:eca184b6-b785-45ce-9462-b5067f667e05@o4g2000pra.googlegroups.com...
> Hello,
>
> I have a large set of numerical data (cells I8:O24607) in which each
> cell has been formatted to have either no fill or one of 5 different
> colored (light yellow, yellow, orange, red, or black) fills. The cell
> values and formatting were copied and pasted into this worksheet from
> other worksheets so there is no conditional formatting applied to the
> current sheet.
>
> The formatting represents a quality rating and I would like to count
> the number of cells that have either no fill or the light yellow fill
> in each column. Is this possible to do using the IF function and
> having the cell fill be the condition and the TRUE value be "1" then
> summing the TRUE values? If so, how do I enter the cell fill as the
> condition? Are there other ways to do this?
>
> Thank you,
>
> Andrea 


0
BobNGs (423)
10/15/2008 5:13:43 PM
Hi,

Excel's spreadsheet functions can't count cells based on formatting, yet.  
But you can do it with VBA.  

The following is fancier than you need but it might give you ideas:

Function CountFormats(R As Range, E As Range) As Integer
    Dim cell As Range
    Dim Total As Integer
    Dim T As Boolean
    Set S = E.Cells(1, 1)
    Total = 0
    For Each cell In R
        T = True
        With cell
            If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
            If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = False
            If .Font.Bold <> S.Font.Bold Then T = False
            If .Font.Italic <> S.Font.Italic Then T = False
            If .Font.Underline <> S.Font.Underline Then T = False
        End With
        If T = True Then
            Total = Total + 1
        End If
    Next cell
    CountFormats = Total
End Function

To use this function you enter

=CountFormats(B2:F13,A1)

What it does is count how many cells in the range B2:F13 have a format that 
matches A1.  It is checking the formatting of bold, italic, underline, font 
color and fill color.
-- 
Thanks,
Shane Devenshire


"amk1023" wrote:

> Hello,
> 
> I have a large set of numerical data (cells I8:O24607) in which each
> cell has been formatted to have either no fill or one of 5 different
> colored (light yellow, yellow, orange, red, or black) fills. The cell
> values and formatting were copied and pasted into this worksheet from
> other worksheets so there is no conditional formatting applied to the
> current sheet.
> 
> The formatting represents a quality rating and I would like to count
> the number of cells that have either no fill or the light yellow fill
> in each column. Is this possible to do using the IF function and
> having the cell fill be the condition and the TRUE value be "1" then
> summing the TRUE values? If so, how do I enter the cell fill as the
> condition? Are there other ways to do this?
> 
> Thank you,
> 
> Andrea
> 
0
10/15/2008 10:14:09 PM
I’ve tried this and it works the first time but does not update if you change 
the format of a cell in the range. The result will change if you copy and 
paste the formula into another cell. I thought that maybe recalculating the 
sheet might work but it didn’t. any suggestions?

"ShaneDevenshire" wrote:

> Hi,
> 
> Excel's spreadsheet functions can't count cells based on formatting, yet.  
> But you can do it with VBA.  
> 
> The following is fancier than you need but it might give you ideas:
> 
> Function CountFormats(R As Range, E As Range) As Integer
>     Dim cell As Range
>     Dim Total As Integer
>     Dim T As Boolean
>     Set S = E.Cells(1, 1)
>     Total = 0
>     For Each cell In R
>         T = True
>         With cell
>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = False
>             If .Font.Bold <> S.Font.Bold Then T = False
>             If .Font.Italic <> S.Font.Italic Then T = False
>             If .Font.Underline <> S.Font.Underline Then T = False
>         End With
>         If T = True Then
>             Total = Total + 1
>         End If
>     Next cell
>     CountFormats = Total
> End Function
> 
> To use this function you enter
> 
> =CountFormats(B2:F13,A1)
> 
> What it does is count how many cells in the range B2:F13 have a format that 
> matches A1.  It is checking the formatting of bold, italic, underline, font 
> color and fill color.
> -- 
> Thanks,
> Shane Devenshire
> 
> 
> "amk1023" wrote:
> 
> > Hello,
> > 
> > I have a large set of numerical data (cells I8:O24607) in which each
> > cell has been formatted to have either no fill or one of 5 different
> > colored (light yellow, yellow, orange, red, or black) fills. The cell
> > values and formatting were copied and pasted into this worksheet from
> > other worksheets so there is no conditional formatting applied to the
> > current sheet.
> > 
> > The formatting represents a quality rating and I would like to count
> > the number of cells that have either no fill or the light yellow fill
> > in each column. Is this possible to do using the IF function and
> > having the cell fill be the condition and the TRUE value be "1" then
> > summing the TRUE values? If so, how do I enter the cell fill as the
> > condition? Are there other ways to do this?
> > 
> > Thank you,
> > 
> > Andrea
> > 
0
Picman (4)
11/7/2008 4:49:02 PM
Add this line of code before the line: Dim cell As Range

Application.Volatile

Then the function will recalculate whenever the file calculates. However, it 
still will not calculate when a format changes. A change in format does not 
trigger a calculation. It's for that reason I discourage using functions 
based on formats. You can also hit function key F9 at any time to 
recalculate.

-- 
Biff
Microsoft Excel MVP


"Picman" <Picman@discussions.microsoft.com> wrote in message 
news:10E5E71D-F3B3-4A2A-A777-B7CE24084B00@microsoft.com...
> I've tried this and it works the first time but does not update if you 
> change
> the format of a cell in the range. The result will change if you copy and
> paste the formula into another cell. I thought that maybe recalculating 
> the
> sheet might work but it didn't. any suggestions?
>
> "ShaneDevenshire" wrote:
>
>> Hi,
>>
>> Excel's spreadsheet functions can't count cells based on formatting, yet.
>> But you can do it with VBA.
>>
>> The following is fancier than you need but it might give you ideas:
>>
>> Function CountFormats(R As Range, E As Range) As Integer
>>     Dim cell As Range
>>     Dim Total As Integer
>>     Dim T As Boolean
>>     Set S = E.Cells(1, 1)
>>     Total = 0
>>     For Each cell In R
>>         T = True
>>         With cell
>>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = 
>> False
>>             If .Font.Bold <> S.Font.Bold Then T = False
>>             If .Font.Italic <> S.Font.Italic Then T = False
>>             If .Font.Underline <> S.Font.Underline Then T = False
>>         End With
>>         If T = True Then
>>             Total = Total + 1
>>         End If
>>     Next cell
>>     CountFormats = Total
>> End Function
>>
>> To use this function you enter
>>
>> =CountFormats(B2:F13,A1)
>>
>> What it does is count how many cells in the range B2:F13 have a format 
>> that
>> matches A1.  It is checking the formatting of bold, italic, underline, 
>> font
>> color and fill color.
>> -- 
>> Thanks,
>> Shane Devenshire
>>
>>
>> "amk1023" wrote:
>>
>> > Hello,
>> >
>> > I have a large set of numerical data (cells I8:O24607) in which each
>> > cell has been formatted to have either no fill or one of 5 different
>> > colored (light yellow, yellow, orange, red, or black) fills. The cell
>> > values and formatting were copied and pasted into this worksheet from
>> > other worksheets so there is no conditional formatting applied to the
>> > current sheet.
>> >
>> > The formatting represents a quality rating and I would like to count
>> > the number of cells that have either no fill or the light yellow fill
>> > in each column. Is this possible to do using the IF function and
>> > having the cell fill be the condition and the TRUE value be "1" then
>> > summing the TRUE values? If so, how do I enter the cell fill as the
>> > condition? Are there other ways to do this?
>> >
>> > Thank you,
>> >
>> > Andrea
>> > 


0
biffinpitt (3172)
11/7/2008 6:20:33 PM
It didn't solve the problem. this is how the code looks now, did i do 
something wrong?

Function CountFormats(R As Range, E As Range) As Integer
    Application.Volatile
    Dim cell As Range
    Dim Total As Integer
    Dim T As Boolean
    Set S = E.Cells(1, 1)
    Total = 0
    For Each cell In R
        T = True
        With cell
            If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
            If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = False
            If .Font.Bold <> S.Font.Bold Then T = False
            If .Font.Italic <> S.Font.Italic Then T = False
            If .Font.Underline <> S.Font.Underline Then T = False
        End With
        If T = True Then
            Total = Total + 1
        End If
    Next cell
    CountFormats = Total
End Function


"T. Valko" wrote:

> Add this line of code before the line: Dim cell As Range
> 
> Application.Volatile
> 
> Then the function will recalculate whenever the file calculates. However, it 
> still will not calculate when a format changes. A change in format does not 
> trigger a calculation. It's for that reason I discourage using functions 
> based on formats. You can also hit function key F9 at any time to 
> recalculate.
> 
> -- 
> Biff
> Microsoft Excel MVP
> 
> 
> "Picman" <Picman@discussions.microsoft.com> wrote in message 
> news:10E5E71D-F3B3-4A2A-A777-B7CE24084B00@microsoft.com...
> > I've tried this and it works the first time but does not update if you 
> > change
> > the format of a cell in the range. The result will change if you copy and
> > paste the formula into another cell. I thought that maybe recalculating 
> > the
> > sheet might work but it didn't. any suggestions?
> >
> > "ShaneDevenshire" wrote:
> >
> >> Hi,
> >>
> >> Excel's spreadsheet functions can't count cells based on formatting, yet.
> >> But you can do it with VBA.
> >>
> >> The following is fancier than you need but it might give you ideas:
> >>
> >> Function CountFormats(R As Range, E As Range) As Integer
> >>     Dim cell As Range
> >>     Dim Total As Integer
> >>     Dim T As Boolean
> >>     Set S = E.Cells(1, 1)
> >>     Total = 0
> >>     For Each cell In R
> >>         T = True
> >>         With cell
> >>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
> >>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = 
> >> False
> >>             If .Font.Bold <> S.Font.Bold Then T = False
> >>             If .Font.Italic <> S.Font.Italic Then T = False
> >>             If .Font.Underline <> S.Font.Underline Then T = False
> >>         End With
> >>         If T = True Then
> >>             Total = Total + 1
> >>         End If
> >>     Next cell
> >>     CountFormats = Total
> >> End Function
> >>
> >> To use this function you enter
> >>
> >> =CountFormats(B2:F13,A1)
> >>
> >> What it does is count how many cells in the range B2:F13 have a format 
> >> that
> >> matches A1.  It is checking the formatting of bold, italic, underline, 
> >> font
> >> color and fill color.
> >> -- 
> >> Thanks,
> >> Shane Devenshire
> >>
> >>
> >> "amk1023" wrote:
> >>
> >> > Hello,
> >> >
> >> > I have a large set of numerical data (cells I8:O24607) in which each
> >> > cell has been formatted to have either no fill or one of 5 different
> >> > colored (light yellow, yellow, orange, red, or black) fills. The cell
> >> > values and formatting were copied and pasted into this worksheet from
> >> > other worksheets so there is no conditional formatting applied to the
> >> > current sheet.
> >> >
> >> > The formatting represents a quality rating and I would like to count
> >> > the number of cells that have either no fill or the light yellow fill
> >> > in each column. Is this possible to do using the IF function and
> >> > having the cell fill be the condition and the TRUE value be "1" then
> >> > summing the TRUE values? If so, how do I enter the cell fill as the
> >> > condition? Are there other ways to do this?
> >> >
> >> > Thank you,
> >> >
> >> > Andrea
> >> > 
> 
> 
> 
0
Picman (4)
11/7/2008 9:47:01 PM
There's nothing you can do about it. As I noted in my other reply, this is 
why I discourage the use of formulas based on formats. Changing a cells 
format does not trigger a calculation. So, when you have formulas based on a 
cells format the formula doesn't update (calculate) when you change the 
cells format. The formula will only update when some other event triggers a 
calculation or you manually force a calculation.

-- 
Biff
Microsoft Excel MVP


"Picman" <Picman@discussions.microsoft.com> wrote in message 
news:9BB5E911-2C66-4BDF-A4EC-C5694FAFFA94@microsoft.com...
> It didn't solve the problem. this is how the code looks now, did i do
> something wrong?
>
> Function CountFormats(R As Range, E As Range) As Integer
>    Application.Volatile
>    Dim cell As Range
>    Dim Total As Integer
>    Dim T As Boolean
>    Set S = E.Cells(1, 1)
>    Total = 0
>    For Each cell In R
>        T = True
>        With cell
>            If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>            If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = False
>            If .Font.Bold <> S.Font.Bold Then T = False
>            If .Font.Italic <> S.Font.Italic Then T = False
>            If .Font.Underline <> S.Font.Underline Then T = False
>        End With
>        If T = True Then
>            Total = Total + 1
>        End If
>    Next cell
>    CountFormats = Total
> End Function
>
>
> "T. Valko" wrote:
>
>> Add this line of code before the line: Dim cell As Range
>>
>> Application.Volatile
>>
>> Then the function will recalculate whenever the file calculates. However, 
>> it
>> still will not calculate when a format changes. A change in format does 
>> not
>> trigger a calculation. It's for that reason I discourage using functions
>> based on formats. You can also hit function key F9 at any time to
>> recalculate.
>>
>> -- 
>> Biff
>> Microsoft Excel MVP
>>
>>
>> "Picman" <Picman@discussions.microsoft.com> wrote in message
>> news:10E5E71D-F3B3-4A2A-A777-B7CE24084B00@microsoft.com...
>> > I've tried this and it works the first time but does not update if you
>> > change
>> > the format of a cell in the range. The result will change if you copy 
>> > and
>> > paste the formula into another cell. I thought that maybe recalculating
>> > the
>> > sheet might work but it didn't. any suggestions?
>> >
>> > "ShaneDevenshire" wrote:
>> >
>> >> Hi,
>> >>
>> >> Excel's spreadsheet functions can't count cells based on formatting, 
>> >> yet.
>> >> But you can do it with VBA.
>> >>
>> >> The following is fancier than you need but it might give you ideas:
>> >>
>> >> Function CountFormats(R As Range, E As Range) As Integer
>> >>     Dim cell As Range
>> >>     Dim Total As Integer
>> >>     Dim T As Boolean
>> >>     Set S = E.Cells(1, 1)
>> >>     Total = 0
>> >>     For Each cell In R
>> >>         T = True
>> >>         With cell
>> >>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>> >>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T =
>> >> False
>> >>             If .Font.Bold <> S.Font.Bold Then T = False
>> >>             If .Font.Italic <> S.Font.Italic Then T = False
>> >>             If .Font.Underline <> S.Font.Underline Then T = False
>> >>         End With
>> >>         If T = True Then
>> >>             Total = Total + 1
>> >>         End If
>> >>     Next cell
>> >>     CountFormats = Total
>> >> End Function
>> >>
>> >> To use this function you enter
>> >>
>> >> =CountFormats(B2:F13,A1)
>> >>
>> >> What it does is count how many cells in the range B2:F13 have a format
>> >> that
>> >> matches A1.  It is checking the formatting of bold, italic, underline,
>> >> font
>> >> color and fill color.
>> >> -- 
>> >> Thanks,
>> >> Shane Devenshire
>> >>
>> >>
>> >> "amk1023" wrote:
>> >>
>> >> > Hello,
>> >> >
>> >> > I have a large set of numerical data (cells I8:O24607) in which each
>> >> > cell has been formatted to have either no fill or one of 5 different
>> >> > colored (light yellow, yellow, orange, red, or black) fills. The 
>> >> > cell
>> >> > values and formatting were copied and pasted into this worksheet 
>> >> > from
>> >> > other worksheets so there is no conditional formatting applied to 
>> >> > the
>> >> > current sheet.
>> >> >
>> >> > The formatting represents a quality rating and I would like to count
>> >> > the number of cells that have either no fill or the light yellow 
>> >> > fill
>> >> > in each column. Is this possible to do using the IF function and
>> >> > having the cell fill be the condition and the TRUE value be "1" then
>> >> > summing the TRUE values? If so, how do I enter the cell fill as the
>> >> > condition? Are there other ways to do this?
>> >> >
>> >> > Thank you,
>> >> >
>> >> > Andrea
>> >> >
>>
>>
>> 


0
biffinpitt (3172)
11/7/2008 10:10:27 PM
Thanks for the help anyway.

"T. Valko" wrote:

> There's nothing you can do about it. As I noted in my other reply, this is 
> why I discourage the use of formulas based on formats. Changing a cells 
> format does not trigger a calculation. So, when you have formulas based on a 
> cells format the formula doesn't update (calculate) when you change the 
> cells format. The formula will only update when some other event triggers a 
> calculation or you manually force a calculation.
> 
> -- 
> Biff
> Microsoft Excel MVP
> 
> 
> "Picman" <Picman@discussions.microsoft.com> wrote in message 
> news:9BB5E911-2C66-4BDF-A4EC-C5694FAFFA94@microsoft.com...
> > It didn't solve the problem. this is how the code looks now, did i do
> > something wrong?
> >
> > Function CountFormats(R As Range, E As Range) As Integer
> >    Application.Volatile
> >    Dim cell As Range
> >    Dim Total As Integer
> >    Dim T As Boolean
> >    Set S = E.Cells(1, 1)
> >    Total = 0
> >    For Each cell In R
> >        T = True
> >        With cell
> >            If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
> >            If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = False
> >            If .Font.Bold <> S.Font.Bold Then T = False
> >            If .Font.Italic <> S.Font.Italic Then T = False
> >            If .Font.Underline <> S.Font.Underline Then T = False
> >        End With
> >        If T = True Then
> >            Total = Total + 1
> >        End If
> >    Next cell
> >    CountFormats = Total
> > End Function
> >
> >
> > "T. Valko" wrote:
> >
> >> Add this line of code before the line: Dim cell As Range
> >>
> >> Application.Volatile
> >>
> >> Then the function will recalculate whenever the file calculates. However, 
> >> it
> >> still will not calculate when a format changes. A change in format does 
> >> not
> >> trigger a calculation. It's for that reason I discourage using functions
> >> based on formats. You can also hit function key F9 at any time to
> >> recalculate.
> >>
> >> -- 
> >> Biff
> >> Microsoft Excel MVP
> >>
> >>
> >> "Picman" <Picman@discussions.microsoft.com> wrote in message
> >> news:10E5E71D-F3B3-4A2A-A777-B7CE24084B00@microsoft.com...
> >> > I've tried this and it works the first time but does not update if you
> >> > change
> >> > the format of a cell in the range. The result will change if you copy 
> >> > and
> >> > paste the formula into another cell. I thought that maybe recalculating
> >> > the
> >> > sheet might work but it didn't. any suggestions?
> >> >
> >> > "ShaneDevenshire" wrote:
> >> >
> >> >> Hi,
> >> >>
> >> >> Excel's spreadsheet functions can't count cells based on formatting, 
> >> >> yet.
> >> >> But you can do it with VBA.
> >> >>
> >> >> The following is fancier than you need but it might give you ideas:
> >> >>
> >> >> Function CountFormats(R As Range, E As Range) As Integer
> >> >>     Dim cell As Range
> >> >>     Dim Total As Integer
> >> >>     Dim T As Boolean
> >> >>     Set S = E.Cells(1, 1)
> >> >>     Total = 0
> >> >>     For Each cell In R
> >> >>         T = True
> >> >>         With cell
> >> >>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
> >> >>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T =
> >> >> False
> >> >>             If .Font.Bold <> S.Font.Bold Then T = False
> >> >>             If .Font.Italic <> S.Font.Italic Then T = False
> >> >>             If .Font.Underline <> S.Font.Underline Then T = False
> >> >>         End With
> >> >>         If T = True Then
> >> >>             Total = Total + 1
> >> >>         End If
> >> >>     Next cell
> >> >>     CountFormats = Total
> >> >> End Function
> >> >>
> >> >> To use this function you enter
> >> >>
> >> >> =CountFormats(B2:F13,A1)
> >> >>
> >> >> What it does is count how many cells in the range B2:F13 have a format
> >> >> that
> >> >> matches A1.  It is checking the formatting of bold, italic, underline,
> >> >> font
> >> >> color and fill color.
> >> >> -- 
> >> >> Thanks,
> >> >> Shane Devenshire
> >> >>
> >> >>
> >> >> "amk1023" wrote:
> >> >>
> >> >> > Hello,
> >> >> >
> >> >> > I have a large set of numerical data (cells I8:O24607) in which each
> >> >> > cell has been formatted to have either no fill or one of 5 different
> >> >> > colored (light yellow, yellow, orange, red, or black) fills. The 
> >> >> > cell
> >> >> > values and formatting were copied and pasted into this worksheet 
> >> >> > from
> >> >> > other worksheets so there is no conditional formatting applied to 
> >> >> > the
> >> >> > current sheet.
> >> >> >
> >> >> > The formatting represents a quality rating and I would like to count
> >> >> > the number of cells that have either no fill or the light yellow 
> >> >> > fill
> >> >> > in each column. Is this possible to do using the IF function and
> >> >> > having the cell fill be the condition and the TRUE value be "1" then
> >> >> > summing the TRUE values? If so, how do I enter the cell fill as the
> >> >> > condition? Are there other ways to do this?
> >> >> >
> >> >> > Thank you,
> >> >> >
> >> >> > Andrea
> >> >> >
> >>
> >>
> >> 
> 
> 
> 
0
Picman (4)
11/10/2008 3:34:01 PM
You're welcome.

-- 
Biff
Microsoft Excel MVP


"Picman" <Picman@discussions.microsoft.com> wrote in message 
news:2B02B53F-F488-40CC-AEE6-C25DD794C05E@microsoft.com...
> Thanks for the help anyway.
>
> "T. Valko" wrote:
>
>> There's nothing you can do about it. As I noted in my other reply, this 
>> is
>> why I discourage the use of formulas based on formats. Changing a cells
>> format does not trigger a calculation. So, when you have formulas based 
>> on a
>> cells format the formula doesn't update (calculate) when you change the
>> cells format. The formula will only update when some other event triggers 
>> a
>> calculation or you manually force a calculation.
>>
>> -- 
>> Biff
>> Microsoft Excel MVP
>>
>>
>> "Picman" <Picman@discussions.microsoft.com> wrote in message
>> news:9BB5E911-2C66-4BDF-A4EC-C5694FAFFA94@microsoft.com...
>> > It didn't solve the problem. this is how the code looks now, did i do
>> > something wrong?
>> >
>> > Function CountFormats(R As Range, E As Range) As Integer
>> >    Application.Volatile
>> >    Dim cell As Range
>> >    Dim Total As Integer
>> >    Dim T As Boolean
>> >    Set S = E.Cells(1, 1)
>> >    Total = 0
>> >    For Each cell In R
>> >        T = True
>> >        With cell
>> >            If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>> >            If .Interior.ColorIndex <> S.Interior.ColorIndex Then T = 
>> > False
>> >            If .Font.Bold <> S.Font.Bold Then T = False
>> >            If .Font.Italic <> S.Font.Italic Then T = False
>> >            If .Font.Underline <> S.Font.Underline Then T = False
>> >        End With
>> >        If T = True Then
>> >            Total = Total + 1
>> >        End If
>> >    Next cell
>> >    CountFormats = Total
>> > End Function
>> >
>> >
>> > "T. Valko" wrote:
>> >
>> >> Add this line of code before the line: Dim cell As Range
>> >>
>> >> Application.Volatile
>> >>
>> >> Then the function will recalculate whenever the file calculates. 
>> >> However,
>> >> it
>> >> still will not calculate when a format changes. A change in format 
>> >> does
>> >> not
>> >> trigger a calculation. It's for that reason I discourage using 
>> >> functions
>> >> based on formats. You can also hit function key F9 at any time to
>> >> recalculate.
>> >>
>> >> -- 
>> >> Biff
>> >> Microsoft Excel MVP
>> >>
>> >>
>> >> "Picman" <Picman@discussions.microsoft.com> wrote in message
>> >> news:10E5E71D-F3B3-4A2A-A777-B7CE24084B00@microsoft.com...
>> >> > I've tried this and it works the first time but does not update if 
>> >> > you
>> >> > change
>> >> > the format of a cell in the range. The result will change if you 
>> >> > copy
>> >> > and
>> >> > paste the formula into another cell. I thought that maybe 
>> >> > recalculating
>> >> > the
>> >> > sheet might work but it didn't. any suggestions?
>> >> >
>> >> > "ShaneDevenshire" wrote:
>> >> >
>> >> >> Hi,
>> >> >>
>> >> >> Excel's spreadsheet functions can't count cells based on 
>> >> >> formatting,
>> >> >> yet.
>> >> >> But you can do it with VBA.
>> >> >>
>> >> >> The following is fancier than you need but it might give you ideas:
>> >> >>
>> >> >> Function CountFormats(R As Range, E As Range) As Integer
>> >> >>     Dim cell As Range
>> >> >>     Dim Total As Integer
>> >> >>     Dim T As Boolean
>> >> >>     Set S = E.Cells(1, 1)
>> >> >>     Total = 0
>> >> >>     For Each cell In R
>> >> >>         T = True
>> >> >>         With cell
>> >> >>             If .Font.ColorIndex <> S.Font.ColorIndex Then T = False
>> >> >>             If .Interior.ColorIndex <> S.Interior.ColorIndex Then T 
>> >> >> =
>> >> >> False
>> >> >>             If .Font.Bold <> S.Font.Bold Then T = False
>> >> >>             If .Font.Italic <> S.Font.Italic Then T = False
>> >> >>             If .Font.Underline <> S.Font.Underline Then T = False
>> >> >>         End With
>> >> >>         If T = True Then
>> >> >>             Total = Total + 1
>> >> >>         End If
>> >> >>     Next cell
>> >> >>     CountFormats = Total
>> >> >> End Function
>> >> >>
>> >> >> To use this function you enter
>> >> >>
>> >> >> =CountFormats(B2:F13,A1)
>> >> >>
>> >> >> What it does is count how many cells in the range B2:F13 have a 
>> >> >> format
>> >> >> that
>> >> >> matches A1.  It is checking the formatting of bold, italic, 
>> >> >> underline,
>> >> >> font
>> >> >> color and fill color.
>> >> >> -- 
>> >> >> Thanks,
>> >> >> Shane Devenshire
>> >> >>
>> >> >>
>> >> >> "amk1023" wrote:
>> >> >>
>> >> >> > Hello,
>> >> >> >
>> >> >> > I have a large set of numerical data (cells I8:O24607) in which 
>> >> >> > each
>> >> >> > cell has been formatted to have either no fill or one of 5 
>> >> >> > different
>> >> >> > colored (light yellow, yellow, orange, red, or black) fills. The
>> >> >> > cell
>> >> >> > values and formatting were copied and pasted into this worksheet
>> >> >> > from
>> >> >> > other worksheets so there is no conditional formatting applied to
>> >> >> > the
>> >> >> > current sheet.
>> >> >> >
>> >> >> > The formatting represents a quality rating and I would like to 
>> >> >> > count
>> >> >> > the number of cells that have either no fill or the light yellow
>> >> >> > fill
>> >> >> > in each column. Is this possible to do using the IF function and
>> >> >> > having the cell fill be the condition and the TRUE value be "1" 
>> >> >> > then
>> >> >> > summing the TRUE values? If so, how do I enter the cell fill as 
>> >> >> > the
>> >> >> > condition? Are there other ways to do this?
>> >> >> >
>> >> >> > Thank you,
>> >> >> >
>> >> >> > Andrea
>> >> >> >
>> >>
>> >>
>> >>
>>
>>
>> 


0
biffinpitt (3172)
11/10/2008 5:57:10 PM
look at ASAPUtilities for functions using cell formats

Eric 


0
ericNOSPAM (46)
11/11/2008 1:21:29 AM
Reply:

Similar Artilces:

Summing 2 columns cells into a 3rd colums cells
In Excel 2007, I need the to add data from column L's cells 2-93 with the data from column M's cells 2-93 and have it total in Column N's cells 2-93. I'm hoping that there is an easier way than auto summing each pair of cells. This example is the smallest range that I have to due this with and auto summing is to time consuming. Please if you have a formula that I can use it would be extremly helpful. Just in case you haven't notice I'm still in the learning stages.................. -- Thank You, Wayne Cadigan Hi Wayne You can still do this ...

Autofit Merged Cells? Can we do this?
I have a row that has merged column cells. Even if I choose autofit, it will not autofit. Is tehre a way to do this? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ If you search the group archives: http://google.com/advanced_group_search?q=group:*excel* using "merge autofit" (without quotes) as search terms, you'll find many posts on this topic, including links to a macro by Jim Rech that may work for you. In article <kenji4861.vwe00@excelf...

Excel-how (find/replace) for multifmat cells w/o changing fmat
For a client, i need to be able to find and replace words in cells with 2 formats. But when you replace them,it changes the format of the whole cell, and not just what you changed. Is there any way to work around this without changing the format after all of the find and replaces? Saved from a previous post, but this one has some wordwrap problems fixed: I think you'd have to keep track of each character's font attributes. This works very slowly, but works: Option Explicit Option Compare Text Type myCharacter myChar As String myLen As Long myName As String myFo...

Pivot table and counting.
I have a pivot table that gives me the number of rides done by a van. I can have the pivot table return the number of rides, but what I need is the number vans that participated for a certain day. Example, it is possible to have 27 trips done by 18 vans, how can I count the number of vans and not addup the van number? Any help appreciated. Thank you, Joe Hi Joe We need a bit more information on how your source data table is set up. What information do you have in each column? -- Regards Roger Govier sacredarms <sacredarms@discussions.microsoft.com> wrote: > I have a pi...

Cell formating in Excel?
Is there a way to have a scroll bar in a single cell? No. -- Best Regards, Luke M "pmarina" <pmarina@discussions.microsoft.com> wrote in message news:5D25B665-B7B8-477D-AAF8-80A347FFA0DD@microsoft.com... > Is there a way to have a scroll bar in a single cell? ...

format question when open csv file
I receive a csv file that I open in excel. The first field in this file is a nine alphanumeric character. When I open the file excel formats that field in how it sees fit. Example 1157687E6 would display in scientific notation. I make a quick update to the file and resave as .csv file. The csv file resaves that field as the scientific notation, so the people I pass this file to have problems with it. Is there a way to open a csv file in excel where excel does not reformat the field or give me an option to not reformat. >> Is there a way to open a csv file in excel where exc...

Set RN = Range(Cells(2, 1), Cells(r, 1)) error
What wrong with this. It create error. How can I improve to get rid the error? Set RN = Range(Cells(2, 1), Cells(r, 1)) Thanks Daniel Hi Daniel, Too much missing information - has r been declared and what data type is it and what value does it have. What property of the range are you trying to store in the variable RN? What type of variable is RN and has it been declared. -- Thanks, Shane Devenshire "Daniel" wrote: > What wrong with this. It create error. How can I improve to get rid the > error? > > Set RN = Range(Cells(2, 1), Cells(r, 1)) > &...

Cycle Counting
Hello, I am looking for ideas on how to cycle count serial number tracked items without increasing workload. Our serialized items are barcoded but the problem is the are situated on the pallet incorrectly and the pallet is placed on a third level of a racking system. If we could just cycle count based on item count and not include the serial number it would make it easy. Is this possible in Great Plains. We are running Great Plains 8.0. Any suggestions are greatly aprreciated. Thank You, Brian Morris Database Administrator ...

To keep in just one cell all values related to a monthly rate
I have to update in a monthly basis a currency rate. I know that there is a function, formula (or something like that) to link a month descripton to a number. e.g. September09 1,325 October09 2,235 November09 1,258 I would like to select correspondent month and the cell be updated with the value. Data Validation dropdown list for choosing the month combined with a lookup table and VLOOKUP function. For help on creating data validation dropdown lists see Debra Dalgleish's site. http://www.contextures.on.ca/xlDataVal01.html For help on VLOOKUP to populat...

Can I limit a cell to 2 characters?
Is there a way in Excel to limit the number of characters in a cell? Thanks Frank By checking the length of the cell =LEN(A1)=2 in your custom validation. Look for Data Validation on Debra Dalgleish's site. --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "Frankc" <Frankc@discussions.microsoft.com> wrote in message news:842747F1-1792-4BB5-B3CE-707C7CC5F88F@microsoft.com... > Is there a way in Excel to lim...

format cells #4
hi. how can i set by default the cell formatting to 'general' or 'number' or even 'text'? i mean i dont want excel to correct let's say: 1.5 to 01.may or 9/12 to 09.dec. is this possible? thanks. (i have some programs which export data to excel and instead of numbers in excel appear dates and i can't set the cell format before the data is exported) -- notrace2004 ------------------------------------------------------------------------ notrace2004's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=34817 View this thread: http://www....

How do I count the # of times a value reoccurs and plot it over ti
I wish to plot a number of errors made by each users and compare it over time. I have a column of user ID's and a column of dates. I want the chart to count the number of times each user ID appears and plot against it's corresponding date. However, each time I try to do this, the chart appears wrong. Any ideas? In article <9595B2A1-8282-4AB3-8511-A6776E108164@microsoft.com>, Stephen@discussions.microsoft.com says... > I wish to plot a number of errors made by each users and compare it over > time. I have a column of user ID's and a column of dates. I want t...

Copying Border Formatting
Hi folks, I have a large spreadsheet which is essentially a diary. I want to format the days and weeks, with thin and thick borders to distinguish between them. The spreadsheet already has lots of varied fill formatting for meetings that are held. I can't see a way of either format painting, or paste special-ing, just borders. Is it possible? Thanks -- StainlessSteelRat http://www.stainlesssteelrat.net Stanley: It's not gonna end like this. Gabriel: Oh, come on, Stan. Not everything ends the way you think it should. Besides, audiences love happy endings. True enough that...

Count
Hi, I would like to know how which formula I should use to count some codes & to ignore the duplicated codes, for example in column A: Code 1234 4321 4321 1234 1234 3214 Now, I want Excel to count & the result is 3 which are: 1234-4321-3214 Yes I can use PivotTable, but I would like to use a formula because I have to deal with this every day. I appreciate your support. -- MFS22 COUNTIF will do it. =COUNTIF(Rng,Rng), where the criterion is the same as the range: e.g =COUNTIF(A3:A8,A3:A8) HTH Peter "MFS" wrote: > Hi, > I wo...

change highlight color on active cells
How do I change the active highlight color of an active cell. Louis Only though VBA. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 'yellow Set OldCell = Target End Sub This is sheet event code. Right-click on the sheet tab and "View Code". Copy and paste into that module. Chip Pearson has a great add-in named Rowliner.xla that will make the highlighting available for all sheets and workbooks. The code above w...

Populate Blank Fields with "0" based on checkmark.
I have a form with 20 fields. The user enters data into some but not all of the fields depending on where they collected data. Is it possible to create a checkbox where, after the user enters their data, they click the checkbox, and any of the 20 fields that are blank get populated with a 0? Thanks for the help. Is there any reason you want them to be zero? If they are numeric fields, you can set the default to zero in table design view. There is no need to use a checkbox, you can arrange it so any empty fields are converted to zero when you move to another record or exit th...

Line count
I am working with a program called Dictaphone. We use Word 2007 in this program. The line count on Dictaphone and the line count in Word 2007 are different even though the Dictaphone text is retrieved from Word 2007. Why would they be different? What is the difference between virutal line count and physical line count? ...

Formatting cells in Excel with Ascending/Descending order
I am trying to insert a drop down asceding/descending arrow in the cell of the excel document. When you click on the arrow which is a small box on the right side of the cell, it will organize all figures/data in that column and you can choose between ascending/descending, or how you want to organize it. Thank you -- Andrew ...

count number of characters in rich edit control
How can i count number of characters in rich edit control 2 If u mean controls of type Rich TextBox control, try RichControl1 RC1; CString Mes=RC.GetText(); int n=Mes.GetLength(); "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i count number of characters in rich edit control 2 EM_GETTEXTLENGTHEX, WM_GETTEXTLENGTH, WM_GETTEXT, EM_STREAM* "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i co...

Filename in Excel Cell Address
Is there a way to insert an excel spreadsheet filename into a cell within the same spreadsheet, like the &[File] command in the Header/Footer screen? -- Thanks, RickS yes =CELL("filename") -- Gary Keramidas Excel 2003 "RickS" <RickS@discussions.microsoft.com> wrote in message news:A801EEC7-608B-4394-B991-BBBC889D451A@microsoft.com... > Is there a way to insert an excel spreadsheet filename into a cell within > the > same spreadsheet, like the &[File] command in the Header/Footer screen? > -- > Thanks, > Ric...

Changing Account Distribution Based on Customer Region
My chart of accounts is segmented by Product and Region. I have setup SOP to use posting Account from Item. In addition, I have setup a User-defined field to identify each customer region in Customer Address. Since I can only have one sale account for an item, I don't want to manually change my account distribution in sales documents everytime I sell to customers in a different region from the default defined for the item. I would like GP to automatically change the Account Distribution so that it substitute the appropriate region segment based on the user-defined field in Customer...

updating time once only when a cell is filled
Hi, Excuse my lack of experience with excel, I tried to get an answer googling for this problem I have, but I didn't succeed yet solving it. I'm trying to fill a form using excel, but I want that whenever a cell is filled, the time it was filled is updated. The problem I find is that time is updated in all the cells whenever a cell is change, do I make myself clear?, imagine I have these table: A B 1 +if(a1="","",now()) 2 +if(a2="","",now()) So initially I have: A B 1 2...

Cell extraction from Multiple worksheets
Hi group, I am new to this newsgroup and am hoping that you can help me out. I took a software/hardware inventory of all the computers in my work's network and imported them all into excel, in their own worksheet. So I have one file, with 128 different worksheets, all containing similar information. What I would like to do is create a new sheet, a summary page, where I can pull the value of the same cell from each sheet and list them. I need to have a list of each computer, with computer name, cpu speed, video card, serial number, ect. If the values that I am searching for are in the same...

Counting sales
I have two different datasets. Each with a common identifier. I need a formula that will reference the identifiers in both datasets and count the number of sales a particular agent made. Example. look up this identifier in the other dataset and then give me the value that is 2 columns over from the identifier in the second dataset. See if this helps: http://contextures.com/xlFunctions02.html -- Biff Microsoft Excel MVP "Dave" <Dave@discussions.microsoft.com> wrote in message news:E7245B37-033F-400E-9CEE-9822BE7CB0F5@microsoft.com... >I have two...

How to retrieve value from specific cell value?
Does anyone have any suggestions on how to retrieve value from specific cell value with specific worksheet? I would like to create a if-statement within macro, If specific cell within specific worksheet = 1 then process following code End If Does anyone have any suggestions? Thanks in advance for any suggestions Eric hi If Sheets("sheet1").Range("A1") = 1 Then MsgBox "run code" Else MsgBox "skip code" End If regards FSt1 "Eric" wrote: > Does anyone have any suggestions on how to retrieve value from specific cell &...