Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Counting columns with 1 instance of a specific value

I need to count the number of columns with a particular value in a
specific row and containing one or more instance of a specific value
within a range of rows. My data is significantly more extensive than
this, but to simplify, imagine a spreadsheet with the following data:

A B C D E F
1 red red red blue blue
2 short X X X
3 tall X X
4 round X

I need a formula (not a macro) that will calculate how many columns
have "red" in row one and an "X" in B2:F4.

The result of my formula should be 2 (because only columns B and D
contain both "red" in row 1 and an "X" somewhere in rows 2 - 4).

I started with the following array formula:
{SUM(IF(B1:F1="Red",IF(NOT(ISBLANK(B2:F4)),1,0),0) )}
This returned 4, because it was counting all of the x in those columns.

How do I evaluate each column in an array individually? I thought
about NOT(ISNUMBER(VLOOKUP())), but can't figure out how to write it to
evaluate each column individually and not the entire array.

Any ideas?

Thanks,

Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Counting columns with 1 instance of a specific value

Robert,

A single formula is difficult at best and impossible at worst because of the
differing row counts of the areas under test.

The best way is to use a helper row of formulas:

=COUNTIF(B2:B4,"X")

in cell B5, for example, copied to C5:F5.

Then the formula

=SUMPRODUCT((B1:F2="red")*(B5:F50))

will return the desired result.

HTH,
Bernie
MS Excel MVP


wrote in message
ups.com...
I need to count the number of columns with a particular value in a
specific row and containing one or more instance of a specific value
within a range of rows. My data is significantly more extensive than
this, but to simplify, imagine a spreadsheet with the following data:

A B C D E F
1 red red red blue blue
2 short X X X
3 tall X X
4 round X

I need a formula (not a macro) that will calculate how many columns
have "red" in row one and an "X" in B2:F4.

The result of my formula should be 2 (because only columns B and D
contain both "red" in row 1 and an "X" somewhere in rows 2 - 4).

I started with the following array formula:
{SUM(IF(B1:F1="Red",IF(NOT(ISBLANK(B2:F4)),1,0),0) )}
This returned 4, because it was counting all of the x in those columns.

How do I evaluate each column in an array individually? I thought
about NOT(ISNUMBER(VLOOKUP())), but can't figure out how to write it to
evaluate each column individually and not the entire array.

Any ideas?

Thanks,

Robert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Counting columns with 1 instance of a specific value

Nice solution. Thanks. The SUMPRODUCT function is something I need to
become more familiar with.

Bernie Deitrick wrote:
Robert,

A single formula is difficult at best and impossible at worst because of the
differing row counts of the areas under test.

The best way is to use a helper row of formulas:

=COUNTIF(B2:B4,"X")

in cell B5, for example, copied to C5:F5.

Then the formula

=SUMPRODUCT((B1:F2="red")*(B5:F50))

will return the desired result.

HTH,
Bernie
MS Excel MVP


wrote in message
ups.com...
I need to count the number of columns with a particular value in a
specific row and containing one or more instance of a specific value
within a range of rows. My data is significantly more extensive than
this, but to simplify, imagine a spreadsheet with the following data:

A B C D E F
1 red red red blue blue
2 short X X X
3 tall X X
4 round X

I need a formula (not a macro) that will calculate how many columns
have "red" in row one and an "X" in B2:F4.

The result of my formula should be 2 (because only columns B and D
contain both "red" in row 1 and an "X" somewhere in rows 2 - 4).

I started with the following array formula:
{SUM(IF(B1:F1="Red",IF(NOT(ISBLANK(B2:F4)),1,0),0) )}
This returned 4, because it was counting all of the x in those columns.

How do I evaluate each column in an array individually? I thought
about NOT(ISNUMBER(VLOOKUP())), but can't figure out how to write it to
evaluate each column individually and not the entire array.

Any ideas?

Thanks,

Robert


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting two columns with specific criteria rjre Excel Worksheet Functions 3 February 13th 09 11:43 AM
Testing same cell across multiple sheets for a string and counting each instance? [email protected] Excel Worksheet Functions 5 March 8th 07 02:57 PM
Counting Rows Then Counting Values in Columns Michael via OfficeKB.com Excel Programming 1 June 1st 05 04:10 PM
Counting unique entries in column A but only if specific values appear in columns B and C markx Excel Worksheet Functions 1 February 10th 05 11:52 AM
Counting columns and specific Dates JulieD Excel Worksheet Functions 2 November 12th 04 01:13 PM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"