+ Reply to Thread
Results 1 to 11 of 11

VBA Create Array For New Worksheets

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Create Array For New Worksheets

    Hi, I wonder whether someone may be able to help me please.

    I'm using the code below to search column B on the "All Data" sheet, and where a unique value is found create a new sheet and use the value from column B as the sheet name.

    Please Login or Register  to view this content.
    The question I have is could someone perhaps tell me please how I can assign a variable to create an array when the new sheets are created.

    I'm assuming that the change is needed here, Worksheets.Add(After:=Sheets(Sheets.Count)).Name = rng.Value but I may very well be wrong.

    Many thanks and kind regards

    Chris

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA Create Array For New Worksheets

    attach please a sample file for testing
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Create Array For New Worksheets

    Hi @patel45, thank you for taking the time to reply to my post.

    Unfortunately the file is large in size, so I was trying, if possible not to this, if that's feasible. I'm just really looking for some guidance which I can then take forward?

    Many thanks and kind regards

    Chris

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Create Array For New Worksheets

    Do you want this one?

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Create Array For New Worksheets

    Another one using your favourite topic
    Please Login or Register  to view this content.
    Last edited by AB33; 08-23-2014 at 01:55 PM.

  6. #6
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Create Array For New Worksheets

    Hi @AB33, thank you very much for coming back to me with this.

    Forgive me, but could you tell me please where you create the array. I see the Array set as the variable but not in the rest of the script?

    Perhaps it's my lack of knowledge.

    Many thanks and kind regards

    Chris

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Create Array For New Worksheets

    Chris,
    The code could lead to lots of errors and wrong outcome. There was not need to create sheet arrays, hence that variable was not used on the code. If you look at my second code , I have amended few lines on the code. If the aim of the code was to create unique names, my second code works well.
    Last edited by AB33; 08-23-2014 at 01:56 PM.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA Create Array For New Worksheets

    Or with advanced filter
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA Create Array For New Worksheets

    Or if you insist on an Array
    This assumes a header in B1
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Create Array For New Worksheets

    Hi @AB33, thank you very much for coming back to me with this with the explanation and amended code which works great.

    All the best and kind regards

    Chris

  11. #11
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Create Array For New Worksheets

    Hi @jolivanes, thank you very much for taking the time to reply to my post and for the solutions you've put together as an alternative method to that shown by @AB33.

    All the best and kind regards

    Chris

+ 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. Replies: 6
    Last Post: 09-25-2013, 10:08 PM
  2. Create an array based off values in another array - exclude blanks
    By clifton1230 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2013, 05:35 PM
  3. [SOLVED] Create 1-col array identifying occurrence count in a 1-col array
    By empsall in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2013, 12:50 PM
  4. Replies: 0
    Last Post: 10-13-2012, 10:13 PM
  5. [SOLVED] How to make an array of workbooks made up of an array of worksheets?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2012, 08:33 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