+ Reply to Thread
Results 1 to 8 of 8

Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

  1. #1
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    Hi thanks for looking,

    please could you help me with the syntax


    Please Login or Register  to view this content.
    I'm not sure how to reference the array object to use it as a variable with 'i'?

    Thanks for your help

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    In the absence of any more information, I *think* you want:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    Are you saying you have multiple arrays? Like Array1, Array2, etc.

    That's what it sounds like, but if so, your code is nonsensical because you have to set a position in an array equal to something. You can't set an array equal to a range.

    However, assuming you have one array (let's call it Array1), and that array contains 6 positions, then:

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    Hi Thanks Kyle. Sorry I posted this in a bit of a rush,

    What I am after, is the ability to concatenate an 'array name' -I have no idea if this is even possible!

    I have -
    Please Login or Register  to view this content.
    I am trying to create a loop which delegates variables to each array, rather than assign the variables individually to each array.


    With the below

    Please Login or Register  to view this content.
    It is filtering my data (representing countries entered by humans - so its variables, now delegated as a number)

    country 1, I am trying to assign to ArrayV1 < with the 1 assigned by 'i'.

    What I need to find is something like Array("ArrayV" & 1) = RNG

    I am not sure how to fully qualify an 'array' or if it belongs to an object group that I could use to concatenate the name?


    Thankyou!

  5. #5
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    Thankyou walruseggman, Yes I will need to change that to

    Please Login or Register  to view this content.
    and remove the fRNG

    I believe leaving as array as 'myarray()' gives a dynamic property and fits to the size rqd
    Last edited by graym463; 11-23-2015 at 11:19 AM.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,803

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    As a guess, it looks to me like you are wanting to learn the concept of "jagged arrays" that I am also learning: http://www.excelforum.com/excel-prog...-practice.html
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    I don't think your code does what you think it does and I'd restructure what you're trying to do, but I digress. You can't do that, I think you want to use a single dictionary object, where each element is what you currently have as an array - you can then reference it by key. Something like:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Looping thru arrays with dynamic names. Array1/2/3/5, how to array(Array & i) syntax?

    Thankyou Kyle123, I will look into scripting.dictionary I have not yet used this

    Thanks MrShorty - I have used Jagged Arrays, this is what I needed! I believe I have interpreted that idea in the below code - it seems to be working


    Please Login or Register  to view this content.

    Thanks again

+ 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] Help with: Range Array SelectCase Loop delete: Array All Sheet.Names
    By dlow in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2015, 07:11 PM
  2. Array looping, increase speed of array macro
    By techrcn in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 11-27-2013, 05:33 AM
  3. Replies: 6
    Last Post: 09-25-2013, 10:08 PM
  4. Loop new messages containing a table, populate a dynamic array, paste array to Excel
    By laripa in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2013, 07:20 AM
  5. [SOLVED] New to arrays-Can I move a column in a 2D array without looping to add data?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2013, 08:13 PM
  6. [SOLVED] New to arrays-how do I build new array while filtering first array?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-03-2013, 05:59 AM
  7. VBA. Syntax issue. Looping array
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2012, 10:17 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