# Average Loop - Calculate Result Separately For Columns

Nov 15, 2012

I've been trying to loop data for column A from row 1 until 6 and print the result on specified cell. But the problem is, it keeps looping until column B,C and D.

I want to calculate average result separately for column B,C, and D without taking the previous data.

Here is the code that I've done.

VB:
Sub Avg()
col = 1
Row = 1
Do
Name = ThisWorkbook.Sheets("Sheet2").Cells(Row, col).Value
If Name <> "#" Then

[Code] ....

I attached my excel. The green box indicate the result that I want : function.xls

## Average Mix Of Positive & Negative Numbers Separately

Aug 6, 2009

I have a column which is populated with profits and losses from a trading account. Here is an example:

Column I
400
200
-100
-150
-50

What I want to do is average all the profits, and average all the losses so I have two numbers - the average winner and the average loser. Continuing with the example from the 5 trades above, the average winner is 300 and the average loser is -100. How can I do this in excel?

## Calculate End Result Based On Cell Contents Of 3 Columns

Jan 13, 2014

I am trying to create a formula that is able to calculate an end result based on the cell contents of 3 columns, the results are predefined in 3 other columns, here D, E & F

For example:

Column A Column B Column C Column D Column E Column F Column G (Results)
Royal Mail 1 100 2.8 2.3 1.2
Royal Mail 2 100 2.9 2.4 1.3
Royal Mail 3 100 3.0 2.5 1.4
DPD 5 200 4.5 2.8 1.5
DPOST 1 100 1.2 3.2 1.7

I am trying to create a calculation that in Column G will work out, IF Column A=Royal Mail AND Column B=1 AND Column C<=100 THEN Answer is [@[Column F]], IF Column A=Royal Mail AND Column B=2 AND Column C<=100 THEN Answer is [@[Column F]], IF Column A=Royal Mail AND Column B=3 AND Column C<=100 THEN [@[Column F]], IF Column A=DPD AND Column B=5 AND Column C<=200 THEN [@[Column E]], IF Column A=DPOST AND Column B=1 AND Column C<=100 THEN [@[Column D]]

Here are an example of what I have tried, amongst many...

=IF(AND(AND([@[Default Post Postal Service]]="Royal Mail"),AND([@[Default Postal Format]]=1),AND([@Weight]<=100)),1,0) Everything is zero.

## Calculate Average On Some Of The Columns In A Pivot?

Jul 1, 2014

I have a pivot table showing actual and forecasted sales per month for diffrent regions/sales channels/segment.

I would like to calculate the average monthly sale, for forecasted and actual data, within the pivot instead of doing it outside in columns to the right of the pivot table.

## Calculate The Average Difference Between Columns

May 4, 2009

I am trying to determine the average reduction amount of appraised property values. I have two columns in my spreadsheet. Column H has appraised value of property. Column I has the accepted value of the property. Sometimes the accepted value is the same as the appraised value, sometimes it is reduced, and sometimes it is rejected.

I want to be able to find the average reduction amount when the accepted value is less than the appraised value and is not rejected.

Column H always shows a numerical value (i.e. \$250,000), but Column I may have a numerical value or show "rejected".

## Calculate Average Using Non-consecutive Columns

Feb 18, 2008

I have data in 3 different columns (A, C, and E) to name a few. I want to average each of these columns, but if any of them include zero values, I want to exclude that from my calculation.

Example:

Column A = 10
Column B = 0
Column C = 3

Right now, my "average" formula, is showing the average as 4.33. (average a5, b5, c5)

The real average I'm looking for is 6.5. What is the best way to setup my formula?

## Calculate Mode / Median And Average Based On Data In 3 Columns

Aug 1, 2014

It's probably best if you open up the attached example spreadsheet that contains sheets "Before" and "After" otherwise it might be pretty difficult to understand what I'm talking about.

So I have this spreadsheet where I have part numbers in column B, status of the orders in Column I and lead times in Column M. What I want to achieve is to get of Mode (col N), Median (col O) and Average (Col P) values of each part number and each of its status using the lead times in Column M. If possible I would only like this on the top lines of each of these. I have done the formulas manually on sheet After so if you click on the formula you can see the range's it covers.

I did create a concatenation in column K (conc of column B and I) as helper column because in theory this might make things a little bit easier.

Now going into second part. I would also like to do something very similar but only using the part number and status "Finished" and get the values in columns T,U, and V on the top row of each part number. I made some blue boxes and arrows to kind of point out the idea.

The solution can be either formula based or macro, it really doesn't matter, however I will intent to use it within macro either way.

## Sort Different Columns Separately And Create Combobox To Filter Data?

Jun 6, 2014

I have a workbook has a "Summary" worksheet. I would like to be able to do the following:

(1) Sort columns D, G, J, M,... (the number of columns are different each time I run the macro that I have).

(2) create a combo box to be able to the data (that sorted in 1) by month (1,2,..., 12).

see the attached file

## Fill In The 3 Criteria Fields, Calculate The Result, Copy The Result, And Place It Into The Correct Place On The Table

Oct 19, 2006

I have a macro that imputs data from an external database and puts it into a temporary worksheet. This data has 3 columns (ID, Date, Amount). I am then making another sheet which has X number of tables (one for each ID), with the years being the column headings, and months being the row headings. ie.

| ID X
| +------+------+------+--->
| | 1999 | 2000 | 2001 |
+------+------+------+------+--->
| Jan | \$100 | \$250 | \$300 |
+------+------+------+------+--->
| Feb | \$200 | \$300 | \$200 |
+------+------+------+------+--->
| Mar | \$300 | \$250 | \$100 |
+------+------+------+------+--->
| Sum | \$600 | \$800 | \$600 |
| +------+------+------+--->

| ID Y
| +------+------+------+--->
| | 1999 | 2000 | 2001 |
+------+------+------+------+--->
| Jan | \$100 | \$250 | \$300 |
+------+------+------+------+--->
| Feb | \$200 | \$300 | \$200 |
+------+------+------+------+--->
| Mar | \$300 | \$250 | \$100 |
+------+------+------+------+--->
| Sum | \$600 | \$800 | \$600 |
| +------+------+------+--->

Currently I have a few hidden fields for the DSUM Criteria. I start making the tables. And then filling in table based off of the month and year. Doing so I need 3 criteria:
>= First Day of the Month
<= Last Day of the Month
= ID #

The problem is it takes Excel too long to fill in the 3 criteria fields, calculate the result, copy the result, and place it into the correct place on the table. Is there another way to get this data into the correct tables faster? Instead of using DSUM?

## Color Cells Based On Average Result

Aug 2, 2008

I have a cell with the following formula: =IF(ISERROR(AVERAGE(A2,C2,D2)),"",(AVERAGE(A2,C2,D2)). I'm using this formula because I want to average the selected cells, but if A2,C2, or D2 are blank I don't want it to return the # DIV/0! error, hence the "ISERROR" part.

Now... I want to conditionally format the cell with the above formula in it so that if it is equal to or greater than 80% it's green. Here's the problem, the conditional format colors the cell green if it is blank too. How do I stop that?
Below is an attached spreadsheet to show what I'm trying to do.

## Loop Return The Result Back In Row

Sep 21, 2009

Col ACol BCol CCol DCol ECol F
row 1811TAX CONSIDERATIONS1TAX CONSIDERATIONS
row 1911TAX CONSIDERATIONS#N/A
row 2011TAX CONSIDERATIONS#N/A
row 2121FLYING FALCON1TAX CONSIDERATIONS
row 2221FLYING FALCON#N/A
row 2321FLYING FALCON#N/A
row 2431IN COMMAND1TAX CONSIDERATIONS
row 2531IN COMMAND#N/A
row 2631IN COMMAND#N/A

I have 5 coulmns of data and in col F I have the following formula in row 18
=VLOOKUP(E18,\$C\$18:\$D\$800,2,FALSE)
the results come back " TAX CONSIDERATIONS"
however the same results comes back in row 21 and row 24......how can I modify this lookup to change when column B changes

## Recursive Loop Function Not Returning Result

Sep 20, 2007

I'm currently working on a program in which some sort of recursive looping seems logical.

The relevant part of the code I've currently written looks like this:

Sub hello()

Dim Max_stream As Integer
Dim j, jj As Integer
Dim P_sum, P_min As Double
Dim antal_in, antal_ut, rad_in, rad_ut, ut1, ut2 As Integer

Application. ScreenUpdating = False
Max_stream = WorksheetFunction.Max(Worksheets("Data"). Range("B65536").End(xlUp).Value)

For j = 1 To Max_stream

The problem with the code above is the last If, in which the function "rekursivloop" calls itself. I don't know if this type of formulation is correct, but for the cases the If condition is TRUE (ie ut1 <> ""), the function does not return any answer. Does anyone see an error in the logic or have some example for how to write similar recursive loops?

## Calculate The IRR, But Showing A #DIV/0 Result

Mar 8, 2009

I'm trying to calculate the IRR, but it keeps giving me a #DIV/0 result. My formula is IRR(R6:R21,0.2), with 20% being my guess for the IRR.

## Search Multiple Sheets Within Report And Then Find Average Of Result?

Jun 6, 2014

Average.xlsxHi

I have changed the attachment to use CSV's

I am trying to create a report that I can enter the codes I am looking for and the formula will search the sheets within the report and once the results are found then find the average of those results.

What I am trying to do is search the codes from Sheet 1 under Outlet and ESA(in Blue) in sheet A,B and C. The problem is the ESA code seen in column I of A,B,C is only used when column L is empty in A,B,C.

Once the relevant codes are found I then need to look for the KPI's seen in sheet 1 B4, B6 and B8, they can be found in A,B,C in column R. then the result comes from column S in A,B or C.

Once the result is found for each code I want to find the average of them, with the answer to populate in yellow in sheet 1

I want the formula to be able to handle more or less codes as well as adjust the formula so I can add more sheets(possible D,E,F,G etc)

## Formula To Calculate Result Based On Range

Dec 13, 2012

I have a scorecard that looks something like this:

90% or greater=3
80%-89%=2
70%-79%=1
0%-69%=0

I need the "cell" to react accordingly and I'm lost.

## If Cell Not Blank, Calculate & Round Off Result

Aug 19, 2008

I would like to be able to round off the decimals resulted in the POV field on my worksheet and have a running total of the entries listed below. This occurs sometimes when the mileage units have decimals. In this example, the POV values display \$1.00, 99 cents, and 93 cents. Their resulting total should be 2.92, but Excel calculates them as \$2.93 due to the additional decimals.

The problem is that if I apply an =ROUND function to the formula in the POV field, while it will display a correct answer if all the date and mileage fields are filled in for which the formula has been applied, it will not give a running total in instances where there are empty date/mileage fields, reporting "VALUE!". Is there a way to force Excel to display the running total?

I have attached the worksheet, with the example above entered in. I have included the formula I've been trying to fix on my worksheet on the bottom as well.

## Compare Multiple Conditions To Calculate Result

Jul 24, 2007

I am trying to compare two types of conditions, one that has 3 variables and the other that has 8 variables (each variable has a numeric range), which places the correct result in F6 and F7 of the atatched spreadsheet.

## Creating A Formula To Calculate A Result That Depends On 3/4 Criterias Been Met

Apr 28, 2008

Firstly its probably best you download the file from below and open it up.

http://www.mediafire.com/?un3smhmdyzt

I need a formula to put in cells in column S on sheet March.

It needs to match up the correct price from sheet 'Container Price List'.

The price that should be displayed depends firstly on the account number, container and waste stream all matching to decipher which line the price is on. Then the price displayed should be the price in the column called 'exchange charge' however if this is 0 it should be the price in the column called 'rental charge'.

So for example, if you look at row 27 in sheet 'March' the price displayed would be �80.39. The formula will look at the account number 'c028' on sheet 'March' and match it to the any of 'c028' on sheet 'Container Price List'. It will then look at the container in sheet 'March' which is RL14 and match it with the ones that are RL14 in sheet 'Container Price List'. Then it will look at the Waste Stream in sheet 'March' which is GEN.C and match it with the GEN.C in sheet 'Container Price List'. The result given should be the exchange charge in sheet 'Container Price List' which in this case is �80.39.

If for example the exchange charge displayed �0.00 then the result given should be the rental charge in sheet 'Container Price List' instead.

## Reading In Average Of Cells Inside FOR Loop

Dec 17, 2013

I'm working within a nested FOR loop. If you notice when I'm Assigning "ECD" I'm trying to average the cells from J (which is row 1) and column 11 to column 12. It keeps on telling me "Application-Defined or object-defined error".

Code:
Sub copytab()
Dim WSName As String
Dim NumbSheets As Integer
Dim NextRow As Integer
Dim i As Integer

[Code] .......

## Formula To Calculate Result Whilst Avoiding Errors Is Too Long!

Jan 22, 2010

I have a formula I've been using for a long time which uses VLOOKUP to find results based on various reference cells, and then adds them up. To avoid errors caused by VLOOKUP not finding anything for one of the references I have also used ISERROR. The formula returns a blank if the calculation returns a zero.

I now need to bring further references in to the calculation but, using the format I have been, the formula is now too long. Here is my extensive formula:

## How To Calculate Average Time

Aug 6, 2014

how to find the average times of two different sets of groups. There are the baseline times and intervention times. Both groups have three subtopics: Time Fell Asleep, Woke Up, and Duration (how many hours I slept). I am not sure how to find the average of each subtopic. Here are the times....

Baseline times:
Fell AsleepWoke UpDuration
2:30 AM10:00 AM7:30 hrs
4:30 AM12:30 PM8:00 hrs

[Code]....

## Calculate Average Percentage

Apr 5, 2012

I have a column of percentages, how do I get an average % rate at the end of my column?

## Calculate Average Across Different Worksheets

Sep 27, 2012

I want to calculate the average for 6 cells across 6 different worksheets.

For instance in sheet 7 i want to calculate what the average of sheet 1 A1, Sheet 2 A1, Sheet 3 A1, Sheet 4 A1, Sheet 5 A1 and Sheet 6 A1 is. However some the cells contain blanks/zeros which are resulting in an error message. The overall figure still needs to be divided by 6 to get the average.

## Match And Calculate Average

Mar 15, 2013

I need to calculate the average based on SKU patterns.

For example, if the SKU begins with "CZD", then take the average SKU that meets that pattern.

SKU
Items Sold

CZD80
45

[Code] ......

## Calculate Average If Condition Met

Apr 3, 2008

I have two columns of data. Column B is age column C is gender. I want to calculate average male age and average female age. Suggestions?

Sample
B C
57 f
53 f
47 m
40 f
42 m

Average female age is ___
Average male age is ___

## Calculate The Average Time

Mar 16, 2004

I need to find the average time it takes students to take exams . I use the following formula =text(end time - start time, "h:mm"). I am able to calculate the amount of time it takes a student to take the exam. Now I need a formula to calculate the average time students take to complete a test. I have over 80 times i need to average. Whenever i try a formula I keep getting 0.

## Array To Calculate Bottom Average?

Jun 10, 2014

I have an array formula in the attached file to calculate the average of the Top 3 (cell F6). I put that same formula in cell F14 to calculate the average of the Bottom 3 (just change the "large" to "small", however it doesn't work. The result shows zero. How do I fix this?

## Calculate Average Price For Various Periods

Feb 14, 2014

Trying to calculate the lost revenue value for when a piece of machinary is offline for a period of time based on the hrly price during that particular period. The machines come on/off line at various times during the year so i am trying to make this a bit dynamic so i only need to add new info and not have to change the formula

Column F - Off date of machine
Column G - Restart date of machine
Column H - Hrly time
Column I - Hrly price

I thought this formula (an array) would work for me

=average(if((Column H>=Column F) * (Column H<= Column G), Column I)) but it only calculates that average price for the first period and not new average prices for other periods.

what adjustments I can make to my formula or is there a better formula to use?

## Calculate The Average Amount Of Days?

Mar 26, 2014

I need to calculate the average amount of days it is taking for files to be processed. Here is the example I have.

Assuming that B1=0 and C1=1 (in the # of days row)

# of Days 0123456789101112131415Total Files
File Count011712113203000000049

## Calculate Daily Average Of The Several Variables

Jun 3, 2009

I'm working on a time series dataset with a time step of 15 minutes. I need to calculate daily average of the several variables. So let column "A" be the "date-time" column, let column "B" be the "variable column" and column "C" be the "average column", I need a function that calculated in C1 cell the average of B1 to B95 cells, in C2 cell the average of B96 to B190 cells, in C3 cell the average of B191 to B285 etc.