Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to write an average formula from VBA- SHOULD BE SIMPLE!

One more...

Dim myRange1 as range
Dim myRange2 as range
dim myRange3 as range
Dim myAverage as range

'set two ranges
with activesheet
set myRange1= .range("b4")
set myRange2= .range("e6")
set myrange3= .range(myrange1,myrange2)
set myAverage = .range("a1")
end with


'write into a cell an average formula
myAverage.formula = "=Average(" & myrange3.address(external:=true) & ")"

By using external:=true, you don't have to worry about if myrange3 is on a
different sheet than myaverage.


cantonarv wrote:

I am trying to do the following :

Dim myRange1 as range
Dim myRange2 as range
Dim myAverage as range

'set two ranges
set myRange1= range(b4)
set myRange2= range(e6)

'write into a cell an average formula
myAverage.formula = "=Average(myRange1:myRange2)"

Thats all!!
However the part (myRange1:myRange2) is incorrect - whats the correct
syntax to write this to the cell. Or if this cannot be done how do I
get from numbers to alpha-numeric cell representation e.g. Cell(1,1) to
Cell(A1) -whats the way of doing this is VBA

Thanks in advance guys


--

Dave Peterson
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
Write formula for simple copy and paste to another cell Kalffiend Excel Worksheet Functions 1 January 12th 10 09:10 PM
Help I need to know how to write a simple formula, not having any cbexcel Excel Discussion (Misc queries) 4 December 7th 06 09:36 PM
simple average formula...can you solve it in principle? krasavchik Excel Discussion (Misc queries) 2 April 25th 06 06:48 PM
How to write an average formula from VBA- SHOULD BE SIMPLE! davidm Excel Programming 0 October 11th 05 01:06 PM
How to write an average formula from VBA- SHOULD BE SIMPLE! Mike Fogleman Excel Programming 0 October 11th 05 12:59 PM


All times are GMT +1. The time now is 06:39 AM.

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"