I'm trying to do something like the following. Let's say I have a string of data in A1:A10. I
know I can take the average of these data (say in cell B1) 'AVERAGE(A1:A10)' but what I want
to do is make something a little more flexible. Sometimes I want to know the average between
A1:A4, sometimes I want to know the average between A3:A8, &c.
I want to have two cells (call them C1 and C2) whose values change the range of the average.
That is, I want to make the average A[C1]:A[C2], such that I can change C1 and C2 and get the
particular average I am looking for.
Any ideas?
Nemesio
Originally posted by NemesioHere's a good page explaining programming loops in VB...
I'm trying to do something like the following. Let's say I have a string of data in A1:A10. I
know I can take the average of these data (say in cell B1) 'AVERAGE(A1:A10)' but what I want
to do is make something a little more flexible. Sometimes I want to know the average between
A1:A4, sometimes I want to know the average between A3:A8, &c.
I want ...[text shortened]... change C1 and C2 and get the
particular average I am looking for.
Any ideas?
Nemesio
http://computerprogramming.suite101.com/article.cfm/how_to_loop_in_cell_range_in_excel
D
Originally posted by RagnorakEr. I don't understand any of that. I'm a novice at spreadsheets, I don't know a thing about Visual
Here's a good page explaining programming loops in VB...
http://computerprogramming.suite101.com/article.cfm/how_to_loop_in_cell_range_in_excel
D
Basic.
Is it impossible in Excel by itself?
Nemesio
Originally posted by NemesioI would use the True/False and IF:THEN formulas. For instance, In D1 I might have the True/False formula to display a 1 for true and a 0 for false. Then in B1 I might have it set up for if D1=1/then AVG.A1:A3. If D1=0/then AVG. A3:A10.
I'm trying to do something like the following. Let's say I have a string of data in A1:A10. I
know I can take the average of these data (say in cell B1) 'AVERAGE(A1:A10)' but what I want
to do is make something a little more flexible. Sometimes I want to know the average between
A1:A4, sometimes I want to know the average between A3:A8, &c.
I want ...[text shortened]... change C1 and C2 and get the
particular average I am looking for.
Any ideas?
Nemesio
Try that.
np
There may be an easier way, but I don't know of it.
In your sheet you want to use, press Alt+F11, bringing up the VB Editor.
Double click on your sheet in the left pane and then paste this code (all italics):
Sub getAvg()
Dim bottom, top
bottom = ActiveSheet.Range("C1" )
top = ActiveSheet.Range("C2" )
ActiveSheet.Range("E1" ).Select
ActiveCell.Value = "=average(" & bottom & ":" & top & " ) "
End Sub
Cell C1 will be the 'bottom' range value and C2 the top range value.
Cell E1 will hold the formula and end result.
Close the editor and back on your Excel sheet press Alt+F8 to bring up the macro dialog. You should see something like 'Sheet1.getAvg'. Just click Run.
Et voila.
EDIT You can change the cell values easily enough in the function to reflect what you need. Just make sure that you enter the range cell values (in the format: A1 or A12 etc.) in the correct cells after changing it in the function and be sure to remember the function will overwrite whatever was in the 'result' cell before running the macro.
EDIT! Stupid smileys! 😠
Originally posted by PalynkaPerfect! Thank you so much, Palynka.
=AVERAGE(Indirect(C1):Indirect(C2))
Then just write the starting cell reference in C1 and the ending cell reference in C2.
And thanks so much to everyone else who tried to give me another way, albeit ones beyond
my Excel capacity.
You rock, Palynka!
Nemesio
Originally posted by PBE6I don't know... I find the Offset function to be handy, if you want to pick out elements in a matrix.
Got any other tricks? I use Excel all the time (just ask those other nerds in the Posers & Puzzles forum), so any tricks will be put to good use, gar-ohn-teed!
It's hard to say... What do you want to do?