Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to find last row with Data, avg last 30, show result on row
Hi,
I've been attempting to write a macro to do this and received prior feedback. First response was I did not need a macro, I can use the formula: =IF(COUNT(A10:A1010),AVERAGE(A1010:INDEX(A10:A1010 ,INDEX(LARGE((A10:A1010<"")*ROW(A10:A1010),31),0) )),0) Even though this works, I can't make heads or tails of this. When I try to break this down into smaller functions, it falls apart What is going on by multiplying ((A10:A1010<")*Row(A10:1010),31)0) Using Nested indexes? What does A1010<"" mean? What are some rules for cell references? How do I make a cell reference a variable? Can somone please dicipher this... for me? Also, what if the number of data points collected has not reached 30 yet? Will this function fail? It does not appear to be failing when I test it with just 3 values, but I dont' really understand specifically what the function is doing. __________________________________________________ __________________ The second response was a macro. Sub Math() Dim lastRow As Long Dim sh As Worksheet For Each sh In Worksheets sh.Activate With sh lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row ..Cells(lastRow, "B").FormulaR1C1 _ = "=average(r[-1]c:r[-30]c)" End With Next sh End Sub __________________________________________________ __________________ There are a few things that I would like it to do differently. I want the macro to (starting from Row 12) find the last row and then average the last 30 entities, and post the result on Row 10. I only need to run the macro on a specific worksheet, not multiple sheets. I want to start the macro running once I get 30 sets of data Also, data is recorded in column's A:AZ, and I have to perform this function on every column throughout the entire spectrum. Every so often, I hit a button to copy and paste special the values to another spreadsheet, so this macro has to continue to run while I run another macro at random intervals. I would like to increase my data field from 1200 points to 12,000 points so I can run my test for anywhere from 1 hour (data collected every 3 seconds) to 10 hours __________________________________________________ __________________ Also, in the statement "=average(r[-1]c:r[-30]c)", is there a way to replace the -1 and -30 with counters to represent the row index number like "x" and "y", where "X"=50 and "y" =80. How do I get the macro to put the answer in a specific Row that I activate versus ..Cells(lastRow,"A"). I want the answer to be displayed on Cells("A12") |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Searching multiple data to show desired result | Excel Discussion (Misc queries) | |||
how do I write a macro to show the find dialog box in excel 2003 | Excel Discussion (Misc queries) | |||
Advanced formula - Return result & Show Cell Reference of result | Excel Worksheet Functions | |||
How identify data of two coulams,Every cell count and show result | Excel Discussion (Misc queries) | |||
I need to find a macro to find data cut and paste to another colu. | Excel Programming |