+ Reply to Thread
Results 1 to 7 of 7

Enter Array formula with VBA

  1. #1
    Registered User
    Join Date
    07-12-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    77

    Enter Array formula with VBA

    Hello all,

    I would like to enter the below formula as part of a macro:

    {=SUM(SUMIF('ORIGINAL DEBTORS'!D2:D30649,Gulf!A2:A213,'ORIGINAL DEBTORS'!BF2:BF30649))/1000}

    I have a list of clients, and a larger list of projects related to those clients (and others), the formula sums the debts for each client in the project list.

    The problem I have is that both ranges will be different each time I run it. I have variables within the code to refer to these ranges but am not sure how to use these within the array.

    Does anyone know if this is possible?

    Many thanks

    Rich

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Enter Array formula with VBA

    Please Login or Register  to view this content.
    Where range1, range2 and range3 are your variables

  3. #3
    Registered User
    Join Date
    07-12-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Enter Array formula with VBA

    Thank you yudlugar, I will have a go at incorporating that.

  4. #4
    Registered User
    Join Date
    07-12-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Enter Array formula with VBA

    Hi,

    I'm getting a type mismatch on the array line, I can't find any error values within the data, and can't see why this would be, have I made an error somewhere?

    Please Login or Register  to view this content.

    Thanks
    Rich

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Enter Array formula with VBA

    You've set your Rng variables as a range, you need to use it as a string in the formulaarray.
    Basically, the variable needs to return:
    "'ORIGINAL DEBTORS'!D2:D30649"
    As it's always on the same sheet though you shoudl be able to use:
    Please Login or Register  to view this content.
    Another thing to note, if you define several variables on the same line like this:
    Please Login or Register  to view this content.
    I'm pretty sure Rng1 and Rng2 will be variants and only Rng3 is a range, you need:
    Please Login or Register  to view this content.
    I'm not 100% on that though, I could be wrong.

  6. #6
    Registered User
    Join Date
    07-12-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    77

    Re: Enter Array formula with VBA

    I'm struggling to get this to work within the context of my macro - still learning. I will keep this as something to work on in my spare time, and move on in the meantime.

    I appreciate your help, thank you very much.

    Rich

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Enter Array formula with VBA

    I'm pretty sure Rng1 and Rng2 will be variants and only Rng3 is a range
    That is correct.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. With VBA Enter Ctrl Shift Enter For Array Formula
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-17-2013, 09:02 AM
  2. Enter array formula into many cells
    By ExcelGal in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-20-2013, 04:34 PM
  3. How Do You Enter Array Formula Via VBA?
    By modytrane in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2009, 03:03 PM
  4. How to enter an array formula?
    By pikapika13 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2006, 10:19 PM
  5. [SOLVED] Proper way to enter array formula
    By Phil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-20-2005, 10:05 AM

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