Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
drumstu
 
Posts: n/a
Default moving the formula "average" over one column in a macro


How do I generate a moving average in a cell - say cell "b4" , i.e.,
"=average(a1:b1:c1)".....and then put it in a macro so when a number is
copied into d1, the formula moves to the adjacent cell c4 and displays
"=average(b1:c1:d1)"?


a b c d
data data data data

formula 1 formula 2 etc....


--
drumstu
------------------------------------------------------------------------
drumstu's Profile: http://www.excelforum.com/member.php...o&userid=26467
View this thread: http://www.excelforum.com/showthread...hreadid=398297

  #2   Report Post  
Blue Hornet
 
Posts: n/a
Default

I'm not sure exactly what you're asking here, because it looks like you
can get to what you want through a simple worksheet function.

For example, if we take the example you've given, where you have A1,
B1, C1, D1 <data, AND a formula1, formula2, formula3, etc. in cells
B2, C2, D2, respectively, then if your B2 formula is written:
=average( $A1:B1) (exactly that way) and then copied over to columns C
and D, then its appearance there will be:
=average( $A1:C1) (in cell C2) and
=average( $A1:D1) (in cell D2).

If you copy these formulas down under another row of "Data" entries
(let's say, for example, your next Data appears on Row 6 (A6, B6, C6,
D6) and you copy the formulas from B2, C2, D2 to your next Formula row
(Row 7), the formulas will reference the same relative columns and
rows. That is, the formulas will be the same except the row numbers
will change to "6" from "1".

Of course, this can be done with a macro, too, but simpler is usually
better unless you have a compelling need for the macro...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value between 2 dates AG Excel Worksheet Functions 11 August 21st 05 05:32 PM
Running total w/2 columns - Excel Anna / Ideal Excel Worksheet Functions 14 August 10th 05 04:28 PM
calculating a weighted average using formula bob green Excel Worksheet Functions 1 August 1st 05 10:33 PM
calculating a weighted average uisng formula bob green Excel Worksheet Functions 1 August 1st 05 06:31 AM
Return Count for LAST NonBlank Cell in each Row Sam via OfficeKB.com Excel Worksheet Functions 12 April 17th 05 10:36 PM


All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"