Use AVERAGEIF Across All files in a folder

eliguillot

New Member
Joined
Dec 19, 2017
Messages
4
I have a file for every workday over the past few months and want to average some of the values that are in the relative same location in each workbook.

I currently have a master workbook that has a list of values that I am using for the "criteria" in the AVERAGEIF formula.

For each item in the A column of my master workbook I want to average all of the instances of it across every file in the directory.

Basically I want to have "=AVERAGEIF(all B columns in the worksheet named "PRODUCTION" in each workbook, the text criteria in the cell next to this one in my master workbook, values in column F of the same row as the subject criteria I'm averaging)

Please let me know if anymore clarification is needed.

I've been doing some research and it seems that a macro would be the best bet. I have never written a macro, but am relatively familiar with coding logic.

I don't know how to write the formula into the macro.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
There doesn't seem to be anything certain to go off here, but an average is sum divided by a count. Maybe do something along the lines of a SUMIF divided by a COUNTIF?

That, or perhaps upload an example of what you are working with and what you are trying to do exactly.
 
Upvote 0
I want to average all the instances across all the workbooks.

For instance, each workbook might have 2-5 of the different criteria that I'm looking for with different values in each workbook. I want to average all of the values across all the workbooks.

The data I am looking to average is production rate.

Different production lines have different rates.

The criteria that I'm using is the name of the production line (route) and the values I want to average are the number of cases/hour.

One workbook might have the route (6/10 Labeling) with a value of 150 and another may have it with 134 and another with 128. I want to be able to average those.
 
Upvote 0
So AVERAGE(AVERAGEIF,AVERAGEIF,AVERAGEIF)?

Or SUMIF+SUMIF+SUMIF/COUNTIF+COUNTIF+COUNTIF.
 
Last edited:
Upvote 0
right, but then I have to do it manually for each workbook. I'm experimenting now with trying to use cells with the date in the same format as the filenames so that as I drag the formula across it will rename the filename that it should look in.

This would only return single values for each day, but that would be okay and possibly even better as I could average them later and then also run other statistic stuff like range, which would also be useful.

I'm unable to use a cell reference as part of the filename in my formula though.
 
Upvote 0
Ok, have you tried using INDIRECT?

B1: =[Sheets.xlsx]Sheet1!$E:$E

is the same as

A1: [Sheets.xlsx]
B1: =INDIRECT(A2&"Sheet1!$E:$E")

*Just note if you have a space in the book name you'll need to include the ' before the name. Since this doesn't get picked up in the INDIRECT you'll need to use "'"& in front of the string for the reference.

INDIRECT also requires the workbook to be open.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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
Back
Top