+ Reply to Thread
Results 1 to 8 of 8

VBA to create multiple worksheets, rename, and insert information all off main sheet ...

  1. #1
    Registered User
    Join Date
    08-02-2012
    Location
    Moline, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    9

    VBA to create multiple worksheets, rename, and insert information all off main sheet ...

    I need to create multiple works sheets based of the part numbers in Column C. Each sheet will need to be renamed to the part number that is shown. Now in each sheet, I need the corresponding Part Number and Description block to auto populate each one. So if I should change the information on the "ALL" worksheet it will automatically change in its correspond Worksheet. My code is already Posted in the Visual Basic screen. I also have a Hyperlink formula in there to hyperlink each part number to the seperate Worksheet.

    I need help creating the code below to do what i need it to.. and possibly combine it into one code.


    Please Login or Register  to view this content.

    Sample1.xlsm
    Last edited by headstrong2740; 08-03-2012 at 09:08 AM. Reason: Solved

  2. #2
    Registered User
    Join Date
    08-02-2012
    Location
    Moline, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    and yes... i spent all day searching the site for a solid answer without much luck.... i think anyway.

    Been on plenty of forums, and that sometimes seems to be the first thing people say.. "did you search?"
    Figured i would throw that out there... I searched

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    There's always a hard way and an easy way. I know you're trying to do it all the hard way in VBA, but it's not necessary. Here's how I would accomplish this.

    1) In your template, put these formulas:

    A2: =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)
    B2: =VLOOKUP(A2, All!$C:$E, 2, 0)

    Don't worry about the error message, it won't matter later.

    C1: =HYPERLINK("#ALL!A1", "Home")
    This little addition will come in handy when you're workbook suddenly has 400 sheets in it.

    2) On the ALL sheet, add another column:

    F1: LINK
    F2: =HYPERLINK("#'" & C2 & "'!A1", "Link")

    Copy F2 down your dataset to create clickable links that WILL work after you run the macro.

    2) Now erase your macros from the ALL sheet module, they don't really go there anyway.
    Insert a standard code module (Insert > Module) and put in this macro:
    Please Login or Register  to view this content.
    You can run this version as many times as you wish because it will only create new sheets if they don't already exist.
    As the sheets are created and named, the cells in A2 and B2 will fill themselves out.
    Also, this macro will put the sheets into the same order in the workbook that they are listed in column C. Nifty little addition.



    So, delete all the other sheets, save your workbook, then try it out.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    08-02-2012
    Location
    Moline, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    unless im doing something wrong.. it works and populates the part number... but the description does not populate. I played with it a little and not sure what is wrong.
    I'll take a look at it more tomorrow back in the office and see

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    DOH, my bad, correct the VLOOKUP formula on the template:

    =VLOOKUP(A2, All!$C:$E, 3, 0)

  6. #6
    Registered User
    Join Date
    08-02-2012
    Location
    Moline, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    Worked Perfectly Now... I kept my hyperlink code that I had... The form I am using does not easily allow for a link... that and the linked cells get copied and placed further left in another column for other information... its redundant but works.

    Thank you for the help... that one single code block makes it nicer on the programming eye.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    No kudos for the "auto ordering of the sheets, too? Hehe.... glad it's working for you.

  8. #8
    Registered User
    Join Date
    08-02-2012
    Location
    Moline, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    9

    Post Re: VBA to create multiple worksheets, rename, and insert information all off main sheet .

    KUDOS!

    The auto Order is very nice.. and the Home link was a great addition that I didnt think about!

    Good ideas

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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