+ Reply to Thread
Results 1 to 15 of 15

Macro To Create New Sheet (and rename it) based on unique values in column

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Macro To Create New Sheet (and rename it) based on unique values in column

    Hi All,

    Is their a macro code which can create new sheets for each unique value in a column and name the sheet that unique value?

    For example:

    Column A
    Car
    Van
    motorbike

    It would create three sheets: Car; van; motorbike

    Help much appreciated.
    Last edited by himynameisiain; 07-31-2013 at 08:59 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Hi John,

    It is only pulling the first value through and not all the unique values in the column. Good start, im just not sure how to change that to look though the whole column. When i run the code above it puts one new tab named, then gives me the following error "run time 1004: method of range '_global' object failed

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Mumps,

    Brilliant! Worked a treat to create new tabs with the names. Thank you.

    You would happened to know a way which will then pull certain criteria in the same row but different columns into those tabs?

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    I would need to know which columns you want to copy.

  7. #7
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Ok.

    It would be columns: b,c,i,m,n

    ty

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    I just want to clarify a few things. In your first post you said
    each unique value in a column
    Does this mean that in column A there may be duplicate values? For example, there may be three occurrences of the word "Sample" in column A. Only one sheet named "Sample will be created. If this is the case, do you want the data from all three rows that have "Sample" in column A to be copied or are all the values in column A unique?

  9. #9
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Yes, there will be several "sample" in column A. However, the rest of the row is unique for that rows "sample".

    I would like in our hypothetical situation the three "sample" instances to be copied over if possible?

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Try:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Hi Thanks. I have been modifying what you prescribe in the example as my deciding column is column c. However, i am stumped on how to get it to work for your latest post. If per chance you could see if anything im missing. Its bugging at the line highlighted in bold saying "subscript out of range"

    Please Login or Register  to view this content.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Use this code to avoid confusion:
    Please Login or Register  to view this content.
    Regarding the error you get, I am assuming that the sheet containg your data is called "Sheet1". If your sheet has a different name, you'll have to change "Sheet1" in the code to match your sheet name. If that's not the problem, please post a copy of your file. It would make it easier to find a solution when working with the actual data.

  13. #13
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Brilliant, thanks! Solved!

    (not sure how to change title)

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    Thank you for the feedback. It was my pleasure. To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

  15. #15
    Registered User
    Join Date
    09-19-2012
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro To Create New Sheet (and rename it) based on unique values in column

    done! thanks again!

+ 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. Create A Copy To A New Sheet & Rename Sheet Based on Cell Value
    By delicard in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-25-2013, 08:56 PM
  2. Create a New Sheet & Rename it Based on Cell Value on Another Sheet
    By delicard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2013, 04:48 PM
  3. [SOLVED] Macro to create new worksheets based on column values in a sheet
    By Arjen@bigpond in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2012, 11:18 PM
  4. Create Workbooks based on Unique Values from a Column
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2012, 04:25 AM
  5. Create Sheets based on unique values in Column
    By Hblbs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-20-2009, 08:25 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