+ Reply to Thread
Results 1 to 9 of 9

refer part of a multi dimension array

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    refer part of a multi dimension array

    I have a 2 dimensional array: ar(1 to 2, 1 to 100). I need to refer to the first element of the first dimension ar(1, 1 to 100) without creating a new one. Is that possible? The reason I don't want to create a separate new array is because I need to use the value of the the second element of the first dimension ar(2, 1 to 100). For example something like:

    Please Login or Register  to view this content.
    Then I want to do something like:

    Please Login or Register  to view this content.
    But I don't think ar(1, 1 to 100) is recognized.

    To give a better explanation, for example, I need to create an array of the worksheet name sorted with their corresponding indexes based on the array of randomized sheet name and their indexes. I know this may not be the best description of my problem and I know there are other ways to achieve this specific goal but I am wondering if an array can be used so I can use it for other purposes. Many thanks in advance!
    Last edited by aprildu; 04-23-2017 at 05:23 PM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: refer part of a multi dimension array

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: refer part of a multi dimension array

    Edit: OP changed requirements
    Last edited by mike7952; 04-23-2017 at 05:36 PM.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: refer part of a multi dimension array

    So you need the names of the worksheets sorted? What are you going to do with the array?

  5. #5
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: refer part of a multi dimension array

    This is just an example to show what I want. It's not about this specific task. It's about if I can get part of the array and use it the way I want.

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

    Re: refer part of a multi dimension array

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: refer part of a multi dimension array

    Perhaps you could use Index, here's a very simple example.
    Please Login or Register  to view this content.
    y will return a 1-dimensional array with the values from A1:D1.

    z will return a 2-dimensional array with the values from A1:A15.
    If posting code please use code tags, see here.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: refer part of a multi dimension array

    @ shg

    I prefer to use Application instead of worksheetfunction because in case of error the Worksheetfunction goes into debug while the Application variant gives error on worksheet but code runs through.
    Also with the Application variant you can easily trap the error using IsError and act accordingly.

    Just a thought.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: refer part of a multi dimension array

    @Shg @Norie @Bakerman. Thanks! However my problem doesn't involve any specific sheet or cells. Also I am trying to generate another array based on the first array but it will be sorted (for example). The problem is I want the second element of my original array to be attached to my newly created array. I tried the code but when I change it to av=[{1,2,3;a,b,c}], the index function throws a 1004 error.

    My goal is to create another two dimensional array based on the first array - such as from [{1,3,2;a,b,c}] to [{1,2,3;a,c,b}]

+ 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. add one dimension to array
    By shaykos in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-04-2015, 10:47 PM
  2. Does filling part of an array from a range re-dimension the array?
    By barryleajo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-04-2011, 10:09 AM
  3. Array dimension declaration
    By yellephant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2007, 08:44 AM
  4. vlookup usage with dynamic & multi dimension arrays
    By pjjclark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2007, 04:02 AM
  5. Array dimension
    By Henrietta Klaus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2006, 11:10 AM
  6. Mutli-dimensional Array to Single-Dimension Array
    By Blue Aardvark in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2005, 05:05 AM
  7. Transferring part of a multi-dimensional array to a range in VBA
    By Bob J. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2005, 11: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