Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default entering formula using VBA

I am trying to determine a syntax for entering formula
using VBA.
For example if
Dim apple as range
Set apple =("b1:b5")
how to make B6 property averaging apple.
Thanks,
Alex
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default entering formula using VBA

Please explane more what you want Alex

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"alex" wrote in message ...
I am trying to determine a syntax for entering formula
using VBA.
For example if
Dim apple as range
Set apple =("b1:b5")
how to make B6 property averaging apple.
Thanks,
Alex



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default entering formula using VBA

Use this Alex

ActiveCell.Formula = "=AVERAGE(apple)"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Alex ekster" wrote in message ...
Thank you very much for your posting.
I am trying to find right syntax to use variable range as an argument in
formula using VBA.
For example how to replace "b1:B5" by a range called "apple" in the
following example:
activecell.Formula= "=AVERAGE("b1:b5")"
Thanks,
Alex



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default entering formula using VBA

Is apple a VBA range variable?

dim apple as range
set apple = worksheets("sheet1").range("b1:b5")
activecell.formula = "=average(" & apple.address(0,0) & ")"

is apple a named range:

activecell.formula = "=average(" & range("apple").address(0,0) & ")"

Take a look under help for .address. There's options to include the $ signs
(absolute references) and even include the worksheet name--if the range comes
from a different sheet:

activecell.formula = "=average(" & apple.address(external:=true) & ")"



Alex ekster wrote:

Thank you very much for your posting.
I am trying to find right syntax to use variable range as an argument in
formula using VBA.
For example how to replace "b1:B5" by a range called "apple" in the
following example:
activecell.Formula= "=AVERAGE("b1:b5")"
Thanks,
Alex

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default entering formula using VBA

I forgot this to add Alex.
For my example use this to name the cells

Worksheets("sheet1").Range("b1:b5").Name = "apple"
ActiveCell.Formula = "=AVERAGE(apple)"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Use this Alex

ActiveCell.Formula = "=AVERAGE(apple)"


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Alex ekster" wrote in message ...
Thank you very much for your posting.
I am trying to find right syntax to use variable range as an argument in
formula using VBA.
For example how to replace "b1:B5" by a range called "apple" in the
following example:
activecell.Formula= "=AVERAGE("b1:b5")"
Thanks,
Alex



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





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
Entering Formula - Cannot select cell as it is hidden by formula Jim Excel Worksheet Functions 0 March 25th 10 07:22 AM
Entering a Formula; Remains a Formula Instead of Calculating billbrandi Excel Discussion (Misc queries) 1 April 3rd 08 12:50 AM
entering a formula Moof Excel Worksheet Functions 5 April 26th 07 03:31 AM
Entering IF formula PamiS Excel Worksheet Functions 4 March 21st 07 01:36 PM
Entering a formula via VBscript Jacqui Hurst Excel Programming 2 July 24th 03 04:19 PM


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