Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Averaging a variable length column

I'm creating a macro that will Open each spreadsheet in a
given directory and copy data from specific cells and
paste that data into a new spreadsheet. I have the macro
working fine for static number of spreadsheets. However,
I need to edit it so that it will work with any number of
spreadsheets I have in the directory. I have it working
except for two related functions. I need to get an
average of each column and the standard deviation.

I ran the macro recorder as I created the average so that
I would have code to start with, but it uses relative
addressing and when I replace the row number (R[-208]C)
with my variable that represents the number of rows it
gives me an error. I've also tried to use use the
following line, but all it does is populate the cell with
the text inside the quotes and does not perform the
calculation (varColumnNames is an array that scrolls
through the columns that need to be calculated, and all
variables are integers).

ActiveCell.FormulaR1C1 = Average(Cells(FirstRow,
varColumnNames(ColumnCount)), (Cells(LastRow,
varColumnNames(ColumnCount))))

Any help or direction would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Averaging a variable length column

vVal = -208
Sstr = "R[" & vVal & "]C"





MyAverage = Application.Average(Range(Cells(FirstRow, _
varColumnNames(ColumnCount)), Cells(LastRow, _
varColumnNames(ColumnCount))))
ActiveCell.Value = MyValue

--
Regards,
Tom Ogilvy


"Doug" wrote in message
...
I'm creating a macro that will Open each spreadsheet in a
given directory and copy data from specific cells and
paste that data into a new spreadsheet. I have the macro
working fine for static number of spreadsheets. However,
I need to edit it so that it will work with any number of
spreadsheets I have in the directory. I have it working
except for two related functions. I need to get an
average of each column and the standard deviation.

I ran the macro recorder as I created the average so that
I would have code to start with, but it uses relative
addressing and when I replace the row number (R[-208]C)
with my variable that represents the number of rows it
gives me an error. I've also tried to use use the
following line, but all it does is populate the cell with
the text inside the quotes and does not perform the
calculation (varColumnNames is an array that scrolls
through the columns that need to be calculated, and all
variables are integers).

ActiveCell.FormulaR1C1 = Average(Cells(FirstRow,
varColumnNames(ColumnCount)), (Cells(LastRow,
varColumnNames(ColumnCount))))

Any help or direction would be appreciated.



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
Right function variable length lundquic Excel Worksheet Functions 5 March 1st 09 10:19 PM
Variable range column summation and averaging Tom Excel Discussion (Misc queries) 2 March 15th 08 04:10 AM
Sum a Column of Variable length Chris G Excel Discussion (Misc queries) 4 November 7th 05 12:25 PM
Performing a function on a column of variable length BeenThereGotLost Excel Worksheet Functions 3 July 1st 05 02:50 PM
Sum a column of variable length? Brian Excel Discussion (Misc queries) 5 February 3rd 05 02:26 PM


All times are GMT +1. The time now is 03:52 AM.

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

About Us

"It's about Microsoft Excel"