Variable Range Averages

Sep 9, 2008

I was able to record a macro that did essentially everything I wanted it to, with the important exception of getting the right selection for the average=() calculation.

My worksheets are set up with multiple variable columns, and multiple data collection stations as rows. The rows are sorted by date, with a blank row dividing the data by month. There may be 50 rows in January, then a blank row, then 4 rows in February, then a blank, then 15 rows in March, etc. I can easily average the monthly values in, say, column N by typing "average(" in the cell where I want the average to be calculated, then selecting the top cell for the month of interest in column N, holding the shift key down, pressing end, pressing the down arrow, and then typing ")".

The macro recorder, however, doesn't seem able to handle this method of selecting the cells to put inside the formula parentheses. If I try to run the created macro on other months, it will average the same number of cells targetted by the initial example (i.e. the month I was working with when recording the macro).

Is there any way to code this operation so it will vary the number of cells averaged, based on the number of data rows present in each monthly group? My research into coding averages is turning up only examples that deal with whole columns or fixed cell ranges.

Since I have a pretty big stack of worksheets to work though, it would be very nice to automate the process, but I'm still fumbling here. Not getting anywhere.

View 9 Replies


ADVERTISEMENT

String Variable To Call Defined Range Variable

Nov 10, 2006

Say you define a public range variable called Inputworksheet and you set it to refer to the worksheet called Inputworksheet. You have a separate string variable with the value Inputworksheet. How do you get this string variable value to call/control the range variable Inputworksheet?

I am getting an excel worksheet value from a lookup function that corresponds to the name of a VBA range variable. Once I have this worksheet value, I would like to use the range variable that has the same name as the worksheet value.

View 5 Replies View Related

Autofill With Range That Is Column Variable And Row Variable

Apr 4, 2008

I am trying to autofill dynamic ranges that have column variables (d) and row variables (x)... I am having a hard time with the syntax on this

View 9 Replies View Related

Set Range Variable Using Variable Row Number

Mar 11, 2008

I am using a variable named " Totals" as a range type to refference the range in a formula. It works the way I have it.

Dim Totals As Range
Set Totals = [U37: AE37]

Now instead of the absolute refference, I would like to change the row refference by an offset of my current row, using a formula with a varriable. The columns stay the same.

View 3 Replies View Related

Autofill In Macro Range Is Constant How Can I Code To Be A Variable Range?

Feb 19, 2010

I am trying to write a macro which will autofill specific columns. The macro will set the range from the start of my autofill to the end of my autofill as a constant range.

The problem I need to get around is the end of my range can always change each time I run the macro. For instance, the first time I run the macro I may only need to autofill from row 4 to row 15. The next time, I may only need to autofill from row 4 to 23 (because of user updates). How can I make the end of my range not be a constant address but variable?

View 6 Replies View Related

Select Range In Worksheet Where Last Cell In Range Is Variable?

Jan 27, 2012

I am trying to write code to select a range in a worksheet where the last cell in the range is variable.

Sub DataTest()
Dim LastColumn As Integer
Dim LastRow As Long
Dim LastCell As range

[Code].....

View 8 Replies View Related

Assign Named Range To A Vba Range Variable?

Jan 25, 2013

I have a named range, called SubjectNamesPastoral on a worksheet called Worksheets("Group to Teacher")

I can't assign the named range to the rngSubjectFamilyRangeOnSubjectUsedSheet variable in vba.

the first two lines of code work fine, the msgbox shows "E100:E105", happy days!

However when I try to assign the same range to the rngSubjectFamilyRangeOnSubjectUsedSheet variable, the debugger runs past the 'Set' line without error, but throws 'error 91' at the second msgbox.

VB:
thisString = "SubjectNames" & strSubjectFamilyOfGroup

MsgBox Range(thisString).Address

Set rngSubjectFamilyRangeOnSubjectUsedSheet = Worksheets("Group to Teacher").Range(thisString)

View 1 Replies View Related

Copy A Range And Paste It Over A Variable Range

Jul 16, 2009

I am using the code below to copy a range and paste it over a variable range.

View 4 Replies View Related

Set Range Variable To Growing Dynamic Range

Mar 6, 2008

I have been working on part of the code for my spreadsheet and it works fine in the spreadsheet “Databaseform” however when I copied the code to my master spreadsheet “Paul_PartLocDBCombo” it does not work, I get the error:

Method ‘ range’ of object ‘_worksheet’ failed
The code is then highlighted in yellow, the code is:
Set rng = wksPartsData.Range("a1", Range("a65536").End(xlUp))

Meaning this part is incorrect but I don’t know why? To work it: go to Databaseform and press start. Enter 7mm in the product field and press find all. It will then return all the matching results in the userform. Its this I want to try and achieve on the other spreadsheet when the button find label is pressed.

View 3 Replies View Related

Rolling Averages

Jun 5, 2007

I am working on a spread sheet and am trying to use rolling averages of the last 3 months. I am using worksheets for each month with a final worksheet containing the 3 mo. rolling average. I tried using a formula with OFFSET and it worked fine if all the data was in 1 worksheet, but did not work for multiple worksheets averaging to another worksheet in the same workbook.

View 12 Replies View Related

Averages With #N/A In Row/column

Jan 13, 2009

I am trying to work out the average volume of our daily downloads. I have used Vlookup to automate this. When there is no data it returns #N/A which is no problem. The problem arises when i try to work out the average for the month or peaks (MAX sum).

I have tried several variations of sumif/if/isna etc etc and am not having much luck. Below is an example of what i am trying to average out:
#N/A620#N/A

That is 4 different days download data - I want it to ignore the 0's and #N/A and return the average for the days we actually had a download.

View 2 Replies View Related

Splitting Averages...

Feb 2, 2009

If I have a varying number of figures(say between 4 and 10) which I want the average of the first half of the set and an average of the second half, is there a function which I can use to calculate this? ie if there is 8 numbers in total then I need the average of the first four and last four... but if there is ten figures total then I need the average of the first five and last five.

View 2 Replies View Related

Getting Averages To Round Up?

Mar 8, 2013

I have a spread sheet with col's that I want to average their totals, but would like them to be rounded up or down.

View 3 Replies View Related

Averages When Using A Filter?

Apr 7, 2013

I am using the formula =AVERAGE('Year 13'!BV:BV) to work out the average value in column BV.

However, I would like the value to change if I filter one of the other columns, is there any way to do this?

View 2 Replies View Related

Automatic Averages

Jul 13, 2007

I am inputing each day the total amount of sales. I am manually doing the averages for past 12 weeks on Monday sheet. I would like when I enter the amount for that week that the cells B84, C84, E84, F84 are automatically updated for the past 12 weeks. I have tried a few different approaches but I keep getting #ref or circular reference

View 10 Replies View Related

Averages From 2 Columns

Jan 6, 2006

We are trying to get an Average between 2 columns that have the same conditions. We have been using an array formula succesfully on data that is on 1 column and I have trying to incorporate an Offset into the formula with no luck.
Here is our latetest attempt, WITHOUT THE OFFSET.
The data is in Column P and Column N

=AVERAGE(IF((('Mill Process Data'!N3:N6650,'Mill Process Data'!P3:P6650>.01)*('Mill Process Data'!N3:N6650,'Mill Process Data'!P3:P6650<.3))*(ISNUMBER('Mill Process Data'!N3:N6650,'Mill Process Data'!P3:P6650)),Mill Process Data'!N3:N6650,'Mill Process Data'!P3:P6650)))

View 10 Replies View Related

Average Of Row Averages

Jan 31, 2012

I want a cell that takes each row in column B and subtracts column A from it... (10-5 for row 1). I want it to do that for all rows and then average that number. This would be easy if I were not using a pivot table with a lot of data.

For example:
Column A Column B
5 10
2 9
6 8
1 4
6 7
1 1
6 2
6 8

View 2 Replies View Related

Working Out Averages

Oct 2, 2006

I havea list of values that I need to work averages out for. Unfortunately, sometimes the values will be a zero and these should be ignored.

I can work out the averages easily enough using the average function, but can't quite figure out a way of ignoring the zeros. Sample data would be :-
week 1 - 3.42
week 2 - 0 (zero)

Using the standard average function, I get an average of 1.71 when I actually want it to have an average of 3.42.

I would prefer a function for this but would settle for a macro even though it would increase the program run-time.

View 9 Replies View Related

Averages Formula

Mar 1, 2007

In the following cells I have an average:

B6,J6,R6,Z6, and AH6 and a total average on cell AP6

How would I go about making a formula for that. The reason why I ask is because all the info I have seen refers to the cells with the averages need to be in sequence or range and nothing about the cells being seperated. I also tried using the countif method, but same prob, the cells need to be within a horizontal or vertical range

View 9 Replies View Related

Averages For Last 12 Entries

Oct 20, 2008

I need to calculate average for last 12 valid entries in a column. I say valid because if there are blanks or zeros in the cell they need to be discounted.

The solution needs to work on percentages as well.

To explain further
Col A Col B
Jan 2007 1
Feb 2007 5
Mar 2007 5
Apr 2007 0
May 2007
Jun 2007 20
Jul 2007 0
Aug 2007
Sep 2007 10
Oct 2007 0
Nov 2007 10
Dec 2007 18
Jan 2008 8
Feb 2008 6
Mar 2008 0
Apr 2008
May 2008 10
Jun 2008 1

The requirement would be to calculate average from Jun 2008 backwards for 12 months where there aren't zero or blank entries.

View 9 Replies View Related

Average From Several Averages

Apr 17, 2007

Column 1 contains the number of times an ad has shown
Column 2 contains the average position of the ad from column 1

Like so,

Ad Impressions.........................Avg Position
Google: 14,220,023..........................3.2
Yahoo: 346,656...............................1.2
MSN: 123,234..................................8.9

Total: 14,689,913............................???


Doing the following,

= Average(B2,B3,B4)

This is not the real average as this is directly influenced by the number of ad impressions...

How can i make a real calculation to give me the true total average position of my ads?

View 9 Replies View Related

Top/Bottom X Averages

Jun 3, 2008

Have a five column worksheet with the column headings run column A1 - E1 and there are currently 112 players filling out the data with many more to come

The 5 Column Headers are as follows:

Player# ... PlayerName ... M/F ... SessionAve ... GamesPlayed

What I need to do I pull out the top 5 male and top 5 female by SessionAve (including ties if possible). Would like the info to look like:

Male Shooter ...Session Ave ...GamesPlayed
Player1 .843% 30
Player2 .837% 35
Player3 .835% 25
etc..

Then Same for Female Players

View 6 Replies View Related

Range Variable

Oct 25, 2007

I have a range "C1:Cx" where i want x to be the value from a value "overallLastRow". How do I write this?

View 9 Replies View Related

Specifying A Range Using A Variable

Oct 26, 2008

This is just a simple question but I can't seem to find the answer in any of the hepl files. I want to refer to a range by using a variable but can't get the syntax right.

for example instead of

View 2 Replies View Related

Sum Variable Range

Feb 19, 2009

I am in need of code to sum the above range. But it is different range every day. My company will add the deposit amounts each day from each deposit sheet.

ie:
48000
80000
12000
3000

200
45000
10000

And so on. I have posted an example spreadsheet if needed. (The portion is green is all that needs to be summed but keep in mind it changes amount of rows included changes each day, and the yellow is where the solution goes, but I can easily change that). There are other formulas needed but I have figured those out. I need to run this macro daily just for the last group.

View 6 Replies View Related

Set Range Of Row To A Variable?

Mar 14, 2012

I have a problem of setting a range of row that might expand regularly.

I tried a simple method but...

Code:

' Count the used range row
Dim count As Integer
Dim usedrow As String
count = ActiveSheet.UsedRange.Rows.count
usedrow = "C" & count
' The items are in A1:A105
Set AllCells = Range("C4:usedrow")

View 2 Replies View Related

Range As Variable

Mar 7, 2008

I left my Excel books at home, so I can't even look up the answer, and it's incredibly frustrating, since I know it's something small that I'm missing.

I've got a code that I want to cycle thru 12 ranges, named "Retrieve1" thru "Retrieve12". This is the snippet of code that I'm having the issue with is:

For I = 1 To X
NextRange = "Retrieval" & I
Range(NextRange).Select
Application.Run Macro:="EssMenuRetrieve"
Next I

I only made the "NextRange" variable because I originally had "Retrieval" & I in the range select statement and it didn't work.

View 9 Replies View Related

Range Variable ...

Dec 9, 2008

I am using this coding

LR = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row

Range("A" & Row.counts & ":" & "D" & Rows.Count).Copy Destination:=Sheets("Sheet2").Range("A" & LR + 1)
And it keeps giving me the error "Object required"

I am trying to copy from A-D and the row is a variable to which row was checkmarked at that time.

View 9 Replies View Related

Sum Of Variable Range

Nov 6, 2006

I am trying to create a spreadsheet that will predict the quantity of a product sold in a given month based on the number of new clients that month and the frequency with which the existing clients will need that product to be replaced. E.g. Washing Up Liquid is required by every new client and they will need a new one each month. Toilet Cleaner is required by every new client and they will need a new one every 3 months.

I have 'hard coded' the two examples into the formula on the "Non-Variable" sheet. However the Frequency of Replacement is speculation; it may traspire that a bottle of Toilet Cleaner only lasts 2 months, in which case I would have to go into each cell and change the formula to reflect this. I believe Add or SUM Every nth Cell may hold the answer but I am failing to get it to work with my data due to being a novice and not really understanding the formulae used! The second sheet is my attempt.

As you can see, it counts 3 months forward from the first month, not 3 months BACK from the CURRENT month. It also simply doesn't work: Washing Up Liquid should equal 285. Ideally I would like to keep the format of the 1st sheet as this matches the rest of the the workbook (not included).

View 4 Replies View Related

Set Variable To End Of Range

Dec 23, 2006

still trying to figure it out how the logic in VBA works

'this selects a block of sells and put them in variable rormu. Right?
Set test = ActiveSheet. Range("i65535").End(xlUp).Offset(-1, -3)
Set test2 = ActiveSheet.Range("i65535").End(xlUp)
Set formu = Range(test, test2)

'here i try to create another variable for a range after last used row
Set newg = ActiveSheet.Range("f65535").End(xlUp).Offset(2, 0)
Set newg2 = ActiveSheet.Range("f65535").End(xlUp).Offset(3, 3)
Set pst = Range(newg, newg2)

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved