+ Reply to Thread
Results 1 to 3 of 3

Array formula in macros

  1. #1
    Registered User
    Join Date
    09-30-2005
    Posts
    4

    Exclamation Array formula in macros


    I am trying to set up a macro that calculates balances per individual per month. When manually setting up the spreadsheet the array formula has returned the correct result but I am getting an error when the formula is included in a macro.

    The error message returned is:
    "Run-time error '1004':
    Unable to set the FormulaArray property of the Range class"


    The relevant section of code is:
    (please note that I have manually wrapped the code below as when I tried to use the underscore character to wrap the formula I get an immediate syntax error)
    The logic of the formula below is that if the values in columns E & F are equal then no value is required (the starting IF stmt). If the values are not equal then the formula will return values from 3 data sheets.
    Please Login or Register  to view this content.
    Hopefully someone can make me
    Last edited by mudraker; 04-20-2007 at 09:41 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Bafana,

    A Formula Array can only be entered into an array of contiguous cells. Range("G2") is a single cell and doesn't constitute an array, hence the error. To enter a formula into single cell use the Formula property.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    09-30-2005
    Posts
    4
    I have tried your suggestion but it has not helped. Using the exact same syntax as shown in the original post, I have another macro in the same workbook that works - the only difference being that the formula listed combines an IF stmt and multiple array components.

    I have tried segmenting the formula into its component parts and the macro will then run correctly. It therefore seems that I am either missing something when combining the individual components into a summarised formula or a macro somehow can't recognise the formula which when entered directly into the spreadsheet, Excel will compute correctly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1