+ Reply to Thread
Results 1 to 10 of 10

Store array formula content in a VBA array

  1. #1
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Store array formula content in a VBA array

    Hello to all,

    In a VBA procedure, how can I store in an array or variable the result of the array formula shown below?
    Please Login or Register  to view this content.
    Thanks in advance for any help.

  2. #2
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Store array formula content in a VBA array

    Hello,

    Somebody knows how to do it?

    Thanks

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Store array formula content in a VBA array

    Is this what you are asking?
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Store array formula content in a VBA array

    Hello jindon,

    The array formula actually is
    Please Login or Register  to view this content.
    and it returns the column numbers in range A1:E1 of
    values in range J1:M1 and if is not present, returns "0". So, this worksheet formula returns something like
    Please Login or Register  to view this content.
    But if I assign in this way
    Please Login or Register  to view this content.
    when I print the value of x only prints the first element. How can I get value i within x variable?

    For example the values in range A1:G1 ar below:
    # A B C D E F G
    1 A B D F R H J

    Values in J1:M1 are:
    # J K L M
    1 D R J K

    So, the formula returns
    Please Login or Register  to view this content.
    Thanks in advance

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Store array formula content in a VBA array

    How are you outputting?

    Please Login or Register  to view this content.
    Note your sample is dealing with horizontal range, if vertical range, you need to transpose other way around.

  6. #6
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Store array formula content in a VBA array

    Hello jindon,

    Yes, thanks it works.

    One more question.

    Now works fine like this (with sheet names and ranges written explicitely/fixed)
    Please Login or Register  to view this content.
    But how can I insert variables to this expression to make it dynamic?, I mean. Replace by variables the sheet names (in red)
    and replace with variables the ranges (in blue)

    something like.
    Please Login or Register  to view this content.
    Because for example I would like to put different sheets names there and for the ranges I have another variable for last column
    used and both parameters are stored in variables.

    I hope make sense,

    Thanks for the help.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Store array formula content in a VBA array

    Short cut notation of Evaluate method [ ] doesn't accept variables.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Store array formula content in a VBA array

    Hello jindon,

    Thank you!

    I'm testing like below, but I receive run-time error 1004, error defined by application or object.

    Please Login or Register  to view this content.
    I'm not sure where is the error here. Var2 contains the name of the sheet.

    Thanks for the help

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Store array formula content in a VBA array

    1) Syntax of Evaluate method must be string, so ActiveSheet.Range(Cells(1, 2), Cells(1, 5)) must be its address.
    Please Login or Register  to view this content.
    2) Also Evaluate method takes address from ActiveSheet, so you need to change the 2nd range like
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    06-07-2011
    Location
    Hnd
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Store array formula content in a VBA array

    Thanks so much.

    It works so fine with your suggestion.

    Best regards

+ 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. VBA store sheetnames in a array
    By oeldere in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-18-2013, 03:39 PM
  2. [SOLVED] Store range into array?
    By matchooo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2013, 06:28 PM
  3. [SOLVED] Store value from an array in new variable
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 05:03 AM
  4. [SOLVED] How do you store a value in an array without quotes?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 10:51 AM
  5. Array does not store value
    By yeaster in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2008, 11:36 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