Need to apply a function to a range of cells over a range of worksheets

aecarr8286

New Member
Joined
Mar 31, 2009
Messages
6
I have a workbook with several worksheets in the same format. I would like to have a function to output the sheets that have rows in which collumn A = X AND collumn B = Y.

I've been working on this one for a couple days now and I'm not making much progress. Any help would be greatly appreciated.

Thank!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,892
Office Version
  1. 365
Platform
  1. Windows
Are you looking to sum a column, based on the specified conditions, and for each sheet? If so, which column?
 
Upvote 0

aecarr8286

New Member
Joined
Mar 31, 2009
Messages
6
Are you looking to sum a column, based on the specified conditions, and for each sheet? If so, which column?

Each worksheet contains data on a "trip". Each row in the worksheet describes an event on the trip. I would like to output a list of trips that contain an event with both an X in collumn A AND a Y in collumn B.
 
Upvote 0

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,892
Office Version
  1. 365
Platform
  1. Windows
Then I think a VBA solution would be more efficient. However, I'll have to defer to others when it comes to VBA.
 
Upvote 0

aecarr8286

New Member
Joined
Mar 31, 2009
Messages
6
How about a count of sheets that contain an event that fulfills those conditions?
 
Upvote 0

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,892
Office Version
  1. 365
Platform
  1. Windows
Do those conditions occur more than once in any sheet or do they only occur once?
 
Upvote 0

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,892
Office Version
  1. 365
Platform
  1. Windows
First, list your sheet names in a horizontal range of cells, for example G2:I2. Then, define the following...

Insert > Name > Define

Name: Array1

Refers to:

=T(OFFSET(INDIRECT("'"&Sheet1!$G$2:$I$2&"'!A2:A100"),ROW(INDIRECT("2:100"))-2,0,1))

**Note that if Column A contains numerical values, change the 'T' in red to 'N'.

Click Add

Name: Array2

Refers to:

=T(OFFSET(INDIRECT("'"&Sheet1!$G$2:$I$2&"'!B2:B100"),ROW(INDIRECT("2:100"))-2,0,1))

**Note that if Column A contains numerical values, change the 'T' in red to 'N'.

Click Ok

Then try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER...

=SUM(IF(MMULT(TRANSPOSE(ROW($A$2:$A$100)^0),IF(Array1="X",IF(Array2="Y",1,0),0)),1))

Note that if you'd prefer listing your sheet names in a vertical range of cells, for example G2:G4, replace...

Sheet1!$G$2:$I$2

with

TRANSPOSE(Sheet1!$G$2:$G$4)

Hope this helps!

xl-central.com
 
Upvote 0

aecarr8286

New Member
Joined
Mar 31, 2009
Messages
6
Works like a charm!!!

Thanks a ton!

First, list your sheet names in a horizontal range of cells, for example G2:I2. Then, define the following...

Insert > Name > Define

Name: Array1

Refers to:

=T(OFFSET(INDIRECT("'"&Sheet1!$G$2:$I$2&"'!A2:A100"),ROW(INDIRECT("2:100"))-2,0,1))

**Note that if Column A contains numerical values, change the 'T' in red to 'N'.

Click Add

Name: Array2

Refers to:

=T(OFFSET(INDIRECT("'"&Sheet1!$G$2:$I$2&"'!B2:B100"),ROW(INDIRECT("2:100"))-2,0,1))

**Note that if Column A contains numerical values, change the 'T' in red to 'N'.

Click Ok

Then try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER...

=SUM(IF(MMULT(TRANSPOSE(ROW($A$2:$A$100)^0),IF(Array1="X",IF(Array2="Y",1,0),0)),1))

Note that if you'd prefer listing your sheet names in a vertical range of cells, for example G2:G4, replace...

Sheet1!$G$2:$I$2

with

TRANSPOSE(Sheet1!$G$2:$G$4)

Hope this helps!

xl-central.com
 
Upvote 0

Forum statistics

Threads
1,190,789
Messages
5,982,926
Members
439,807
Latest member
WXM86

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top