+ Reply to Thread
Results 1 to 16 of 16

Using Array() with wildcard

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Smile Using Array() with wildcard

    See Below.
    Last edited by ReeceT; 08-18-2011 at 04:38 AM.

  2. #2
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Wink Re: Using Array() with wildcard

    Hi,

    I have a pice of code that I am using to hide sheets. As the workbook grows the need to amend the code becomes quite laborious.

    Is it possible to use a wildcad to shorten this array sequence below:

    Please Login or Register  to view this content.
    The sheets are refering to the CodeName as opposed to the SheetName.

    I tried

    Please Login or Register  to view this content.
    but it does not like it.

    Thanks

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using Array() with wildcard

    Hi ReeceT, adapt your code to something like the following:
    Please Login or Register  to view this content.
    Let me know how it goes for you.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  4. #4
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    Can't get it to work. Sorry am quite new to VBA. This is the whole code that I am using:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using Array() with wildcard

    Hi ReeceT,

    Try
    Please Login or Register  to view this content.
    Last edited by Mordred; 08-17-2011 at 10:19 AM.

  6. #6
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    Grrr.... I am useless...

    Using that code it does not auto hide the sheets anymore.

    I have attached the file if this helps....

    Many Thanks
    Attached Files Attached Files

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using Array() with wildcard

    I'm sure you are not useless so don't think it.

    Edit: Nevermind my ramblings !

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Using Array() with wildcard

    Hi ReeceT,

    I have asked for help from the true gurus of this site. I'm sure your problem will be solved soon.

  9. #9
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    I have sheets with the code name as master 1,2,3,4 as can be seen in the VBA window to the left. These sheets are always on show as they are the heading sheets. Their actual sheet names are Ttile, P&L, Site Info and PVE.

    Now when I click into say the sheet named "P&L" with the codename Master2 the 5 other P&L sheets appear. Then if I click onto "Site Info" with the codename Master3 the 5 P&L sheets hide and the "Site Labour" and "Site Costs" sheets appear.

    I have to use the codenames as this then allows the operator to change the sheet name on the tab without messing up the code and getting errors.

    Now with this simple example there are only 4 Master sheet codenames, however this is likley to increase to over 15 when I use on the full model,

    I would like the ability to add a wildcard ib the array so that I done have to add or delete a CodeName Master sheet everytime I create one.

    Cheers

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: Using Array() with wildcard

    How about:
    Please Login or Register  to view this content.
    Anyone who confuses correlation and causation ends up dead.

  11. #11
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    Thanks for that. That is one hurdle over, however, this code would work for the Master1 only. I need to replicate for the code contained within Master2, Master3 and any further Master sheets created also.

    If I use that code then the hidden sheets within the other CodeName Master2-4 disappear.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: Using Array() with wildcard

    I don't really know what your basis is for hiding, but you basically extend that principle. So you can use:
    Please Login or Register  to view this content.
    or whatever your test is for hiding/showing them.

  13. #13
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    Basis for hiding is that I often have workbooks with 50 or so tabs and it is a pain selceting them by scrolling or right clicking on the arrow.

    If I have heading tabs then it works in much the same was as grouping on the windows taskbar.

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,308

    Re: Using Array() with wildcard

    I wasn't asking why you were doing it, but what the coding logic would be. You need to extend the logic of the codename like "blah*" to hide/show the ones you want for a given situation.

  15. #15
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    I will give it a go hen I get home form work. Thanks for the help.

  16. #16
    Registered User
    Join Date
    08-11-2011
    Location
    Northampton, England
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Using Array() with wildcard

    Sorted now. Thanks romper

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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