Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to use an array function in a macro


Can an array function be executed from a macro, how?

I'd like to construct an array function like

{SUM(IF(A$1:A$500<B1,C1:C500, 0))}

in a macro and call it .. using smthg similar to Application.Worksheetfunction


TIA








  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default How to use an array function in a macro

The formula can be included in a macro as:

ActiveSheet.Range("D1") = "=SUM(IF(A$1:A$500<B1,C1:C500, 0))"

I don't know if this is what you were looking for.
--
Best wishes,

Jim


"Bharath Rajamani" wrote:


Can an array function be executed from a macro, how?

I'd like to construct an array function like

{SUM(IF(A$1:A$500<B1,C1:C500, 0))}

in a macro and call it .. using smthg similar to Application.Worksheetfunction


TIA








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to use an array function in a macro


Thx Jim, but this is not what I was looking for. I want a cell .. say D1 ..
to contain the result of the array function ...

Cells.formulaR1C1 does not work

The array formula is constructed dynamically in the macro, and I'd like the
macro to execute the array formula, and store the result in a cell




"Jim Jackson" wrote:

The formula can be included in a macro as:

ActiveSheet.Range("D1") = "=SUM(IF(A$1:A$500<B1,C1:C500, 0))"

I don't know if this is what you were looking for.
--
Best wishes,

Jim


"Bharath Rajamani" wrote:


Can an array function be executed from a macro, how?

I'd like to construct an array function like

{SUM(IF(A$1:A$500<B1,C1:C500, 0))}

in a macro and call it .. using smthg similar to Application.Worksheetfunction


TIA








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to use an array function in a macro

Heres a short script that will help:
'If you just wanted to output the actual formula to the cell and
execute then:
Sheet1.Range("D1").FormulaArray = "=SUM(IF(A$1:A$500<B1,C1:C500,
0))"

'If you actually want the code to calculate the value and then
output the value:
answer = Evaluate("=SUM(IF(A$1:A$500<B1,C1:C500, 0))")
Sheet1.Range("D1") = answer

Regards

Bharath Rajamani wrote:
Thx Jim, but this is not what I was looking for. I want a cell .. say D1 ..
to contain the result of the array function ...

Cells.formulaR1C1 does not work

The array formula is constructed dynamically in the macro, and I'd like the
macro to execute the array formula, and store the result in a cell




"Jim Jackson" wrote:

The formula can be included in a macro as:

ActiveSheet.Range("D1") = "=SUM(IF(A$1:A$500<B1,C1:C500, 0))"

I don't know if this is what you were looking for.
--
Best wishes,

Jim


"Bharath Rajamani" wrote:


Can an array function be executed from a macro, how?

I'd like to construct an array function like

{SUM(IF(A$1:A$500<B1,C1:C500, 0))}

in a macro and call it .. using smthg similar to Application.Worksheetfunction


TIA









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
OR function in array-entered IF function veggies27 Excel Worksheet Functions 8 March 11th 08 06:32 PM
Returning an Array from a called function within a macro [email protected] New Users to Excel 1 May 18th 07 03:47 PM
Macro with Array Function Problems Brett Excel Worksheet Functions 5 January 10th 06 09:50 PM
VBA Array Function Arishy[_2_] Excel Programming 7 September 27th 05 07:51 PM
Array function Johan de Kok Excel Programming 3 May 14th 05 09:54 PM


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