+ Reply to Thread
Results 1 to 9 of 9

Compare cells to named range and create new sheets using related named range

  1. #1
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Compare cells to named range and create new sheets using related named range

    Hello all,
    Please see attached example. Looking for some help to ignore sheets with the same names and create new sheets by comparing the value on the Maintenance sheet column D to the named range 'CustomerNumber' which is in column A. The code should take the corresponding value from the named range in column 'B' 'CustomerName' (add the underscore between names like Robert_Jones), compare it to the current sheets, and create any sheets that do not exist using the converted customer name as the name of the sheet before the Maintenance sheet. The code should also create a hyperlink on the Summary sheet for every customer sheet created and a link back to the Summary sheet in cell A1 of the created customer sheet. If there is a way to sort the customer sheets (or all sheets) alphabetically that would be great.

    Thanks in advance!!
    Andrew
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    Made a change to the Maintenance sheet to more accurately show the possible values and added some code to kinda do some of what I need.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Compare cells to named range and create new sheets using related named range

    Here is the solution for everything but the sheet sorting:

    Please Login or Register  to view this content.
    There is already existing code out there for sheet sorting. Here is one example I found:

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    Thanks stnkynts!! Both of those work perfectly for my example spreadsheet so I will keep this open a bit until I do production testing. There is a lot more involved but hopefully I have enough example code to do the rest. I think this was the hardest part. I was working on some code that was about 5 times longer than what you provided and I had not even started on the sheet sorting...

    Andrew

  5. #5
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    I started testing with production examples and found that the code errors out when it reaches a field that does not have text separated by a space since the code is trying to insert a '_' between the words. So instead of creating a sheet for John Doe, the sheet needs to be created for John. I'm guessing there needs to be an If/Else added to check for a field with a space between the text and if not, the Else kicks in and the sheet is created with just the single word. Can you make the modification you think is will work the best?

    Andrew

  6. #6
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    Tried the below modified code but

    Please Login or Register  to view this content.
    gives me a run-time error 1004 "Method 'Range' of object'_Global' failed"

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    Made a change and now the code runs all the way through but it is only creating the sheets for cells with a first and last name..not the cell with a single name.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    Figured it out...

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-30-2009
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    496

    Re: Compare cells to named range and create new sheets using related named range

    The code does a great job of adding the "_" between the t words in the cell but can it be modified to add "_" between multiple words? Some of the cells contain 5 or 6 words. I already have to tril the actual words down some to meet the 31 character limit but I still need "_" between the words.

+ 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. [SOLVED] Create the same named Range across multiple sheets
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-07-2015, 01:15 AM
  2. [SOLVED] create MsgBox for cells within named range
    By bob07904 in forum Excel General
    Replies: 6
    Last Post: 02-22-2015, 10:33 AM
  3. Create a named range of cells BUT variable in reference to a cell value
    By peponfree in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-13-2014, 12:46 PM
  4. Replies: 3
    Last Post: 06-22-2012, 06:40 PM
  5. Replace a value in a column with related value in a Named Range
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2008, 09:14 PM
  6. Replies: 1
    Last Post: 06-03-2006, 10:55 PM
  7. Compare a selected Range with a Named range and select cells that do not exist
    By PCLIVE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 03:05 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