LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formulas in VBA

Tom,

Thanks for the help - however, I don't always have a list which is fillled
with numbers - It's basically a list that grows or shrinks (based on the
number of years of data I have for a certain product.) and includes blank
cells at times. What I do know is how many rows of data I'd need at any
particular point. There may be times when I had to average a list of 10
rows, or at times an average of 6 rows.
I need to display the formula as well - is there any way to do this?

Thanks,

Haas



"Tom Ogilvy" wrote in message
...
Assuming your data starts in Cell A1 and has no blank cells down to the

last
cell.

Range("A1").End(xldown).offset(1,0).FormulaR1C1 = _
"=Average(R1C1:R[-1]C1)"


or

Cells(rows.count,1).End(xlup)(2).FormulaR1C1 = _
"=Average(R1C1:R[-1]C1)"

Regards,
Tom Ogilvy


"Haas" wrote in message
om...
HELP!!!

I need to show a formula in a cell which would calculate the average
of a list of numbers. Recording a macro yielded the following results:

Range("A25").Select
ActiveCell.FormulaR1C1 = "=average(R[-18]C:R[-3]C)"


Here's the problem: the list of numbers is always either growing or
shrinking, so the formula would not always be in Cell A25, and we
wouldn't always be offsetting by 18 rows, etc. This would be simple to
do if I din't need to show the formula itself, but I have to.

I tried the following:

a = -18
b = -3
Range("A25").Select
ActiveCell.FormulaR1C1 = "=average(R[a]C:R[b]C)"


(This was done for example purposes - I will be using offsets to
achieve selecting a growing or shrinking range...)

I received an error message - I guess you can't use an R1C1 convention
with variables. Is there another way to do this? I need to show the
formula in the cell due to data manipulation purposes; also, this
would be part of a program which would have other calculations and a
requirement has been that formulas be shown.

Any help on this matter will be greatly appreciated!

Thanks,


Haas





 
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
Convert Array Formulas to Regular Formulas Domenick Excel Worksheet Functions 6 August 17th 15 09:16 PM
E2007 formulas display as formulas, not results Pierre Excel Worksheet Functions 3 January 14th 10 04:59 PM
Counting # of Formulas in a column with formulas and entered data Brand Excel Worksheet Functions 1 October 10th 09 01:01 PM
CELLS NOT CALC FORMULAS - VALUES STAY SME FORMULAS CORRECT?? HELP Sherberg Excel Worksheet Functions 4 September 11th 07 01:34 AM
Formulas not evaluated, Formulas treated as strings Bob Sullentrup Excel Discussion (Misc queries) 0 November 27th 06 08:01 PM


All times are GMT +1. The time now is 04:22 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"