+ Reply to Thread
Results 1 to 6 of 6

Dynamic Array Problems

  1. #1
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35

    Dynamic Array Problems

    Hi all

    I'm trying to create a dynamic array so that when a user enters the first sheet name via an input box, excel will know to select the other sheets with ending (2), (3), (4) etc.

    Currently this code works only if there are 4 sheets present (as I set this way), anything lower/higher is out of range.

    How do I make it so that it will select sheets if there are less than 4 sheets present?

    I tried nesting, but I pretty sure this array needs redimming or something. Is ubound a better option?

    Any input would be most helpful!

    Cheers


    Danny

    Please Login or Register  to view this content.
    Last edited by l8sk8r; 11-20-2008 at 02:48 PM.
    /
    ----
    OOO

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    This will create an array containing all worksheets named with the prefix user enters.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Thanks for you help on this!

    The code works fine except this way causes to pick up everything after the string which is what i am trying to avoid

    say if I enter 'AH' and it will pick up AH, AH (2), AH (3) and AH (4) along with AHM, AHM (2), etc..

    Anyway to get round this?

    Cheers

    Danny

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    You code add a couple more tests.
    Must end with a ) and contain a (
    You could even add another test to check text within ( ) is numeric.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Yeah I tried to a couple of different variations using left, right, instr but ran into issues with the first sheet. I have managed to affix my original code into this. Luckily it gives me the result I wanted. It's pretty ugly but thought I'd post it up.

    Thanks for your help andy. Much appreciated.

    Cheers

    Danny

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482
    Thanks for posting your code.

    To resolve the issue with the sheet that matches you could add a test to check length of name matches when right closing bracket is not found.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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