+ Reply to Thread
Results 1 to 12 of 12

No VBA method to create a dynamic array constant

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    No VBA method to create a dynamic array constant

    Dear All:

    I am looking for a way (without VBA) to create a dynamic array constant which has the value of {1,1,1;2,2,0;3,0,0} in column 3 and {1,1,1,1;2,2,2,0;3,3,0,0;4,0,0,0} in column 4.. and so on and so forth

    This is where I have reached so far:

    I was able to figure out that an array formula =CHOOSE(TRANSPOSE(A1:C1),{1,1,1},{2,2,0},{3,0,0}) where A1=1,B1=2,C1=3 gives me the solution and =A1*--(A1:A3<D1) gives me the value of {1,1,1}.. but when I try combining the above two into a single forumla as =CHOOSE(TRANSPOSE(A1:C1),A1:C1*--(OFFSET(A1:C1,0,0,1,C1)<D1)).. i am returned the value of {1,2,3;#VALUE!,#VALUE!,#VALUE!;#VALUE!,#VALUE!,#VALUE!}....

    I cant seem to figure out how to get the above formula to work or some other way to get the constant {1,1,1;2,2,0;3,0,0}.

    Please do help.

    Thanks
    Akshay

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: No VBA method to create a dynamic array constant

    or some other way to get the constant {1,1,1;2,2,0;3,0,0}
    I'm sure I'm missing something, but why not just enter it exactly like that?

    What's the purpose?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: No VBA method to create a dynamic array constant

    shg:

    its part of a more complex formula. you are missing the dynamic part of the query. .. Please read my first sentence, "I am looking for a way (without VBA) to create a dynamic array constant..."

    Also this requirement is for 60 columns so entering the 20th row would be something like {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0.......20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
    If i try to enter it manually, it would become very cumbersome...lol

    I hope that answers your query..?
    Last edited by akshaythakker; 09-02-2016 at 08:14 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: No VBA method to create a dynamic array constant

    Maybe, except that a constant is constant - a dynamic constant is an oxymoron.

  5. #5
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: No VBA method to create a dynamic array constant

    couldbe, but its what its called... a array constant.... ! so you dont think you can help? you are here just to poke fun at the vagaries of the excel naming systems?

  6. #6
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: No VBA method to create a dynamic array constant

    so basically it is an array "constant" where the diagonal contains the "row number" of the matrix dimensions, everything above the row is the same as it's row number, and everything below the diagonal is 0?

    Just trying to envision the respected results. You want it to change as we drag it to the right?

    Actually, this seems rather over-complicated due to the changing dimensions, would be tons easier to create a VBA solution and just make a helper column in a non-macro book if you just don't want a macro enabled workbook...
    Last edited by TheN; 09-02-2016 at 09:46 PM.

  7. #7
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: No VBA method to create a dynamic array constant

    TheN, thats exactly what i Got. a diagonal and zero below the diagonal. but could not figure out how to get the solution. Could you please explain how to do the vba solution with a non-macro book as I need to share the model with others who dont like to open macro enabled books for obvious reason.

    Thank you in advance!

    Akshay

  8. #8
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: No VBA method to create a dynamic array constant

    I don't know how to do VBA that well yet (not familiar enough with syntax), but I can think of how to do it in programming language, so it is definitely possible with VBA.

    Someone could write a UDF that would work off the row numbers to create the desired arrays. From there, you just copy them into a different workbook and save them for reference. That's my suggestion, so I suggest you update your title as to not scare away the appropriate people. Basically you'd create a "cheat sheet" using a macro then just use it in your non-macro book, if that makes sense.

  9. #9
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: No VBA method to create a dynamic array constant

    Never mind! I was able to figure it out eventually! took some complex trial and errors but nothing feels better than being able to solve a nagging array!

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: No VBA method to create a dynamic array constant

    Via a UDF:

    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    1
    A1: {=ak()}
    2
    3
    1
    1
    B3:C4: {=ak()}
    4
    2
    0
    5
    6
    1
    1
    1
    C6:E8: {=ak()}
    7
    2
    2
    0
    8
    3
    0
    0
    9
    D10:G13: {=ak()}
    10
    1
    1
    1
    1
    11
    2
    2
    2
    0
    12
    3
    3
    0
    0
    13
    4
    0
    0
    0
    14
    15
    1
    1
    1
    1
    1
    E15:I19: {=ak()}
    16
    2
    2
    2
    2
    0
    17
    3
    3
    3
    0
    0
    18
    4
    4
    0
    0
    0
    19
    5
    0
    0
    0
    0


    Please Login or Register  to view this content.
    Last edited by shg; 09-03-2016 at 02:55 PM.

  11. #11
    Registered User
    Join Date
    08-30-2016
    Location
    India
    MS-Off Ver
    2010
    Posts
    8

    Re: No VBA method to create a dynamic array constant

    Thanks shg.. I was looking for a non vba approach and as i mentioned earlier, i was able to figure out a way which turned out to be very simple. But thank you for taking the time to make this function for me.

    Best regards,
    Akshay

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: No VBA method to create a dynamic array constant

    You're welcome.

+ 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. [SOLVED] Determining dynamic array length on a constant number of observations
    By lostest in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-13-2015, 04:28 PM
  2. [SOLVED] Array Constant
    By zanshin777 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-22-2015, 09:58 AM
  3. [SOLVED] Need to create a dynamic array of cell references for MINVERSE
    By ATLGator in forum Excel General
    Replies: 1
    Last Post: 03-26-2012, 10:49 AM
  4. how to create dynamic chart range when 1 axis is constant
    By jrtaylor in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-14-2011, 06:26 PM
  5. create a dynamic array skipping #N/A and blank rows?
    By William DeLeo in forum Excel General
    Replies: 5
    Last Post: 11-10-2010, 02:55 PM
  6. Constant Array
    By ffffloyd in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-08-2010, 04:36 AM
  7. Can you create dynamic named ranges containing array formulas?
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-28-2006, 09:10 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