+ Reply to Thread
Results 1 to 9 of 9

Macro to Add Sheets

  1. #1
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Macro to Add Sheets

    I have data on sheet "Imported Data" containing branch names in Col J.


    I have tried to write code to create a new sheet if it does not already exist, based on each of the unique branch names in Col J and to copy the data pertaining to each branch (Col A:COL J) to the respective sheet that was added

    I get subscript out of range when running the code


    I have attached my sample data


    It would be appreciated if someone could kindly assist me
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Macro to Add Sheets

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to Add Sheets

    Thanks for the help Ben

    I now come up with Next without for and cannot seem to be able to resolve this

    Kindly check & amend
    Attached Files Attached Files

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

    Re: Macro to Add Sheets

    Another possibility
    Please Login or Register  to view this content.

  5. #5
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to Add Sheets

    Thanks for the help. Code works perfectly

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Macro to Add Sheets

    Please Login or Register  to view this content.

  7. #7
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to Add Sheets

    Thanks for the help.


    How do amend the code, so that the sheets are added after "Imported data" sheet ?

  8. #8
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Macro to Add Sheets

    Sheets.Add(After:=sheets("Imported data")).Name = K

  9. #9
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: Macro to Add Sheets

    Thanks very much

+ 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. [VBA] Tricky request! Moving sheets, calling macro within macro, applying to all sheets.
    By excelfriend1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2016, 10:48 PM
  2. [SOLVED] Regression macro on multiple sheets, excluding certain sheets
    By sfostrom in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-12-2016, 05:16 PM
  3. Replies: 2
    Last Post: 09-19-2013, 04:22 AM
  4. [SOLVED] Macro to Unprotect sheets-unlock range of cells-protect sheets
    By jrace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2013, 10:45 AM
  5. Creating a macro to print only the sheets and portion of sheets that i select.
    By cadamhill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2012, 01:48 PM
  6. Replies: 0
    Last Post: 10-10-2012, 08:56 AM
  7. [SOLVED] Macro for filter on protected workbook that works for all sheets, no matter what sheets are named?
    By StargateFanFromWork in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2006, 02:35 PM

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