+ Reply to Thread
Results 1 to 6 of 6

Cycling through arrays

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Cycling through arrays

    After using some lengthy code that is now getting a little out of hand I've decided to rationalise it to make it easier to read and hopefully to amend.

    The code I am working on to try and prove to myself it can be done is as follows:

    Please Login or Register  to view this content.
    So the idea is that when the function is called it cycles through the arrays with the suffix "_sel" to find out which one the contents are contained in. So for exampleif the function sends Z the result should be CT_sel. The tables_sed array is to try and cycle through all the tables but I fear this is where it is all going wrong. CAn anyone help me out? TIA

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

    Re: Cycling through arrays

    Why not use an array of arrays?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Cycling through arrays

    I think that was where I was trying to go, well it looks like it at first glance. Hopefully I'll get a better chance to examine it more closely later. Thanks.

    Once it has found the right _sel it needs to go to another function to get the actual result. So for instance it goes to CT_sel(rate). I can make the string necessary but not 100% sure how to call another function from what is basically a variable.

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

    Re: Cycling through arrays

    Might be an idea to explain what you are trying to do, perhaps some sample data even.

    What I posted was solely based on the code you posted so is without context.

  5. #5
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Cycling through arrays

    What you gave me was bang on my man. As I was building it in steps I was tackling problem one.

    At the moment what happens is I use a case statement based on a flag that is set. So for instance if the argument passed was A it would then DC_test would resolve as"DC_test=IT_sel(rate)". Rather than end up in a series of case statements again what I'd like to do is one line using the result "IT_sel" etc. But I've a feeling if I do "DC_test=table_needed(rate)" it won't come up right as it will be looking for the function table_needed rather than IT_sel.

  6. #6
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Cycling through arrays

    SORTED!

    Went with this.

    Please Login or Register  to view this content.
    Thanks for the help there. I'd have been stuck there forever!

+ 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. Cycling through workbooks
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-09-2016, 12:49 PM
  2. Cycling through Sheets
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2016, 10:24 AM
  3. Replies: 1
    Last Post: 10-10-2012, 07:09 AM
  4. Macro is cycling
    By robfet in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-07-2011, 08:12 PM
  5. Cycling Formula
    By yinyang in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-02-2007, 05:44 PM
  6. [SOLVED] Not cycling through each sheet
    By Michael Smith in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2006, 03:50 PM
  7. cycling through columns?
    By Kirk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2005, 03:06 PM

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