+ Reply to Thread
Results 1 to 22 of 22

Store sheets into array via loop to copy to new book

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Store sheets into array via loop to copy to new book

    Hi all

    I suck with arrays....My scenario as follows:
    I have 7 checkboxes on a frame on a user form
    I am wanting to loop through checkboxes populate sheets based on True value of cb into array and copy those sheets only to newbook and save in selected path...
    This is what i have so far...
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    K sorted...Now as the sheets contain Tables another problem arises...

    Please Login or Register  to view this content.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    K, this seems to work...Thanks All
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Store sheets into array via loop to copy to new book

    Talking to yourself again @sintek
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    @kev...Yep, method in my madness...Keeps me sane lol

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Alrighty then, so this worked last night but now....no more. have uploaded a sample. Perhaps someone can assist...

    Edit...so for those of you that have just tuned in. What i am trying to achieve is the following:
    Dependent on the check box values, I want to store those sheets into an array and then copy and save to a selected path.
    Each sheet contains a Table though...
    Edit2...
    Code runs on a normal range, but not with tables....


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 09-18-2017 at 06:47 AM.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Gees guys...thanks so much for all the responses...I couldn't keep up lol....
    This crappy workaround does the job...Will still like to figure out a better solution.
    Please Login or Register  to view this content.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    Hi,

    Not much point in the array there- you might as well copy each sheet in your first loop.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Nice one xlnitwit...Thanks
    Please Login or Register  to view this content.

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    Just one last thing- this line
    Please Login or Register  to view this content.
    will be true not only for checkboxes but also for optionbuttons and togglebuttons. It is safer to use TypeName if you only want to process checkboxes
    Please Login or Register  to view this content.

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Coolio...Thanks...so i am assuming there is no workaround to original problem...

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    This is the workaround. You just can't copy multiple sheets at once if any of them contain a Table, whether you do it manually or via code. You could alternatively convert the tables to ranges, copy the sheets then reinstate the tables, but that would involve considerably more work.
    Last edited by xlnitwit; 09-18-2017 at 08:09 AM.

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Thought this was to good to be true...
    https://blogs.office.com/en-us/2009/...list-or-table/

  14. #14
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    I guess I stand corrected- I had never seen that before. It does work with your sample workbook, for me at least- after changing the sheet names put into the array.

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Please upload the code correction that allows it to work.

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    All that I did was to add the relevant sheet name in the Tag property of each checkbox and then amend the code thus
    Please Login or Register  to view this content.

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    I sincerely think that you have solved the initial problem posted...What am I missing xlnitwit...
    Please Login or Register  to view this content.

  18. #18
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    Nothing- it worked for me.

  19. #19
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    just my luck then....Untitled-1.gif

  20. #20
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    Can you post the revised workbook? I can only test in 2010 currently but do have 2007 at home somewhere.

  21. #21
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,026

    Re: Store sheets into array via loop to copy to new book

    Here you go...thanks for your time.
    Attached Files Attached Files

  22. #22
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Store sheets into array via loop to copy to new book

    That definitely works in 2010. I'll try to test in 2007 later.

+ 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. search and copy all sheets in a new work book
    By gauti14 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2017, 01:35 PM
  2. Copy w/sheets from a w/book to another w/book
    By tkraju in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2016, 02:37 PM
  3. [SOLVED] Dynamic Changing Data, Based on Criteria Store in Array, Sum array and store in Cell
    By penbeacho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2015, 10:31 AM
  4. macro to copy sheets in workbook to new book
    By tjdarla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2014, 10:28 AM
  5. copy all sheets from a book to an individual book
    By swelyan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2011, 04:02 PM
  6. Copy All Open Sheets to a new book
    By graeme86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2007, 03:54 PM
  7. [SOLVED] store sheets listed in listbox in array
    By Orhan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2006, 05:20 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