+ Reply to Thread
Results 1 to 16 of 16

Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear Forum,

    I need to get the Sheet Names of all the Sheets except a few Sheets viz the Parent SHeet in which these Names have to be displayed and also 1 or 2 Additional Sheets..which are not required to be included such as Sheets which are required to store Data Validation Elements and other information but not meant for the specific operation of the Sheet Names Data to be added.

    Example:

    Total\100\105\List1\List2\141\32

    Now as seen above there are 7 SHeets in all and from the 7 Sheets I want to actually work only from the Sheets which are 100\105\141\32 and this list needs to be shown in the Range from O2 till whatever "O"RowNo till SHeets are added..
    So Now it will be just O2:O5 FOR 4 Sheets.

    I want this List to appear instantly as and when any NEw SHeets are added or removed, but I also dont want to include 3 Sheets one is the Parent SHeet where the List is to appear that is the SHeet "Total" and the other Sheets are List1 and List2.

    So, Preferably, I dont want to mention the Name "Total" as this Name if changed the code should not cease to work some Active.Sheet Fundaa can be used but for other Sheets i.e List1 and List2 I can explicitly mention them somewhere in the code which I get as HELP.

    OR Have a List of NON-Required SHeets OR maintain a pattern that the Sheets which are not reuired will start as NON-List1 so we can tap the word "NON"

    SO, please allow these changes to be incorporated in the VBA code so that in future too I can add any SHeets such as List3 and still not include them in the list and more importantly this has to be instantenous as there are certain NON_VBA approaches which give the List but do not update immediately..

    Warm Regards
    e4excel
    Attached Files Attached Files
    Last edited by e4excel; 01-09-2012 at 12:18 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    perhaps: http://www.excelforum.com/excel-prog...=1#post2673188 will be of interest.

  3. #3
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    Wow thats exactly what I needed however, I am not able to use it because of my limited VBA skills..

    http://www.excelforum.com/excel-gene...le-sheets.html

    Please find the code which I have changed but not followed completely..

    Please Login or Register  to view this content.
    I have commented the Name DEfine portion and then I did not quite follow whether the UCASE would be needed in my case?
    ANd I want the actual Range to be in the COlumn O starting from 2 till no of relevant sheets..but used temporarily in COlumn Q

    Actually I did not know of this WOrkbOOK Sheet Activate Event..!

    New thing learned is of Multiple cases followed by a comma and then I did not understant the comment 'ignore , I mean is there something which needs to be written differently to actually ignore or thats good as it works in your sample file but in my effort I get all the SHeet Names including the Parent TOTal as well as List1,2 and others in the same order as their placement..

    Warm REgards
    e4excel
    Last edited by e4excel; 01-07-2012 at 02:53 AM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Quote Originally Posted by e4excel
    I did not quite follow whether the UCASE would be needed in my case?
    VBA is Case Sensitive by default so if using a UCASE comparison (so as to remove case sensitivity) you must convert all values accordingly:

    Please Login or Register  to view this content.
    See also: Option Compare Text in VBE Help

    Quote Originally Posted by e4excel
    I did not understant the comment 'ignore
    It is merely a comment to reiterate the fact that for those select sheets nothing should happen (you do not want them in your sheet listing)

    Quote Originally Posted by e4excel
    I have commented the Name DEfine portion...
    Can I ask why ?

    If as expected you intend to use this listing in your 3D SUMIF you need to ensure you detail only valid sheets.
    Without a Dynamic Named Range should you modify the workbook (adding/removing sheets) you would in turn have to manually adjust the INDIRECT range in your 3D SUMIF Formula to pick up the revised sheet list range (which will change size).
    Using a Dynamic Named Range negates this, the INDIRECT within the 3D SUMIF will utilise the Dynamic Named Range [_3DList] and thus the formula automatically adjusts as you modify workbook contents.

    Please Login or Register  to view this content.
    Quote Originally Posted by e4excel
    I want the actual Range to be in the COlumn O starting from 2 till no of relevant sheets..but used temporarily in COlumn Q
    To revert to Column O change c_col Constant accordingly.

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    The reason I had commented as before thinking of this query I had tried using a Formula for getting the SHeet Range using INDEX..

    Please Login or Register  to view this content.
    and used the same..


    First I tried putting the Manual values in the Column O and then used this formula to get the Defined Name for the SHeetRange.

    ANd therefore I commented the Name as I wanted to try it with the Automatic Sheet List first..

    NO the problem is After updating the code my file has gone in a long processsing...

    I am opening and Re-opening the file and trying to remove the code as unable to do anything..
    Last edited by e4excel; 01-07-2012 at 05:53 AM.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Please Login or Register  to view this content.
    Last edited by snb; 01-07-2012 at 08:03 AM.



  7. #7
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    I was not aware of the 3D SUMIF till i studued your solution from the other threads but anyways I am still unable to open the FIle so what do I do now?

    @ Snb,

    I can try your code only when I can open the file so will come back soon on that..

    REgrds

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    You can also use the workbook_open event:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    Luckily, I was able to open my file after a long wait...

    I still do not know what was the problem that it was making it go haywire

    I want to also add that I changed a few things in the ShtRng code..

    Please Login or Register  to view this content.
    TO

    Please Login or Register  to view this content.
    Initially, I was this code to get the SheetNames in the COlumn O using a formula
    Please Login or Register  to view this content.
    ANd the code in the Column O

    Please Login or Register  to view this content.
    By virtue of this code I was not able to eliminate the Unwanted SHeetnames as well as it was not instantenous..

    Now, please tell me whether any of this could have caused this Processing Error.

    @ Snb - Give me some time before I check your code too...but thanks anyways for the help...

    Warm Regards
    e4excel

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    e4excel, I am afraid I have no desire to get involved in another 50 post thread

    The code (event) provided previously does exactly as you requested; it will generate a physical sheet listing which can in turn be utilised within a 3D SUMIF and which will update as and when sheets are added, removed, renamed etc...

    The dynamic named range that utilises this listing (in my code 3D List) is utilised subsequently via standard approach:

    Please Login or Register  to view this content.
    In the attached (taken from previous thread) the INDIRECT utilises R1C1 notation for sake of extension.

    If you are experiencing other issues (resulting from a multitude of pre-existing Volatile Arrays and SUMPRODUCTs) I am afraid that's an altogether different matter and not something that should be investigated on this thread.
    Attached Files Attached Files
    Last edited by DonkeyOte; 01-07-2012 at 09:08 AM.

  11. #11
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    I know that the Slowness is something with my codes but I was not able to understand that..as I thought there are just three DEfined Names and which really surprised me that this cause slowness of this magnitude..

    Honestly, in this query I had asked only for the SheetNames however luckily you already had a similar solution in place actually not even similar but exactly the same query..
    SO I got more than I had asked but the only thing was that me unbeknownst of this query had already used the MCgimpsey approach to get to the solution except for geting the SheetNms..

    Back to your query its amazing but actually I am not able understand every bit as I have never used the R1C1 reference..and there are 2 Defined Names which I dont see being used and therefore not able to understand their use.

    Please Login or Register  to view this content.
    So can you please explain the query is already solved its just for understanding purpose...

    I am attaching the File which I made for reference and one more thing in my Sheet if the Columns in the Sheets 100,141,32 etc if the Month Columns were not at the exact location there's no way to counter that..

    Warm REgards
    e4excel
    Attached Files Attached Files

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Quote Originally Posted by e4excel
    there are 2 Defined Names which I dont see being used and therefore not able to understand their use
    _test: as the name implies.

    _3DListK:
    in the original thread from which this is taken the OP asked to also see how they might store the sheet names as defined constants rather than as a range

    I would reiterate the point regards using the defined name creation in the code... there's no need to add more overheard (to establish the named range) given it will always be affected by the Event itself.

    Further, it will reduce risk of error - as is the case in your sample where ShtRng defintion is incorrect:

    Please Login or Register  to view this content.
    Your INDEX will return 4 as there are 4 entries in that column - i.e. O2:O4 ... you must either adjust for blank header or use an alternate approach.

    Quote Originally Posted by e4excel
    ...if the Columns in the Sheets 100,141,32 etc if the Month Columns were not at the exact location there's no way to counter that
    Assuming each sheet could differ then I would be inclined to modify the Sheet event to invoke the calculations via UDF calls or sub routine.

  13. #13
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    FWIW, attached is an alternative route which uses UDF to calculate.

    Given you are updating the sheet list via the Workbook_SheetActivate Event I do not believe this UDF need be Volatile - were you updating the list manually it would given implicit precedents.
    In this instance the act of rebuilding the Sheet Listing should flag all dependent UDFs as requiring recalculation and this will be done each time the result sheet is activated.
    The caveat to this would be using Window Splits to view multiple sheets simultaneously - this would require the UDF be Volatile to see changes reflected real time
    VERY LATE EDIT: and / or referencing "result" cells on other sheets which might be activated post changes but prior to result sheet being activated.

    The UDF is below:

    Please Login or Register  to view this content.
    I have also modified the Event slightly

    Please Login or Register  to view this content.
    You will note in the sample that I have (re)moved columns around on the source sheets; I am also only using 2 Defined Names (one as created by the Event, the other based off Total sheet to determine matrix range).

    The above will work as before re: sheet addition / removal / rename etc...

    Before anyone should choose to critique / amend etc please bear in mind the above is merely a starting point for e4excel ... it is not meant as an all encompassing solution to the issue of 3D conditional aggregation.

    808314_e4excel.xlsm
    Last edited by DonkeyOte; 01-10-2012 at 04:29 PM. Reason: attachment issues !

  14. #14
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Thanks lot DOnkeyOte , you ar truly amazing but it will take a while for me to understand the working...
    I presume the exclusive funtion UDF cannot be anyways replaced by any function or a different Formula approach as I had tried to un-succesfully to change the MOnth Column Location in each different Sheet and then use the SHtRng in the Match Function in my code but it did not produce diffferent COlumn Ranges in the SUMPRODUCT..

    Wish I could also rep..you but I think I have exceeded the no of times I have reputed you..

    @ Snb, thanks a lot SNB for the solution they work too...
    Got to learn about these Events..

    Finally closed...

    Warm Regards
    e4excel

  15. #15
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Quote Originally Posted by e4excel
    I had tried to un-succesfully to change the MOnth Column Location in each different Sheet
    Not entirely clear to me what you mean by the above. If you modified the month header positions within the pre-defined [and consistent] matrix range then the UDF will automatically account for this and vary the column to sum on a sheet by sheet basis.

    Given the sample file I attached illustrated the above concept I am assuming this is not what you mean. If the matrix is located in ranges unique to each sheet then the UDF as originally presented will cater for that. Were you to "name" the top left cell of each matrix on each sheet you could modify accordingly.

  16. #16
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Getting a list of Sheet Names by excluding certain Sheet Names instantenously..

    Dear DO,

    Sorry if there was a misunderstanding, I was just expressing my futile effort.
    No nothing to do with your file at all, this is before I got the final solution from you in the last file, I was trying to make some improvisations in the exisiting formula which was un-succesful..

    Please Login or Register  to view this content.
    In the above code which I was using I was trying to put the range of MonthRng with the new SheetNames which is not possible as I was follishly thinking..

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    Was expecting that the Match Function with the cortsey of the SUMPRODUCT Co-ercion would produce different Column Ranges for differen sheets based on the Match Values..

    This was the way I was doing..

    Warm Regards
    e4excel

+ 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