+ Reply to Thread
Results 1 to 2 of 2

Copy Sheets and Rename

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    6

    Copy Sheets and Rename

    Hi,

    I have the following code that is supposed to take input from a control sheet called 'input' which has file path and name that is supposed to be in cells A5 (the name of the sheet to be renamed), C5(the file path) and D5(the file name) and E5(C5&D5). I want the macro to be able to scroll through rows 5-13 and open up the file in the specified file path, copy a sheet called "attestation" and paste it back in the original controlfile. I would then like the tab that was just copied to be pasted at the last sheet in the controlfile and renamed based on the cell value of the input tab cell A5.

    I would then like to put a formula in the cells of the new sheet and lastly close the workbook that the sheet was copied from.

    I would then like this macro to scroll through the rows 5-13 and end up with 9 new tabs in my controlfile.

    The code pasted below is what I have so far; but I'm not sure why it only copies 5 of the sheets as opposed to 9 and the rename doesn't work.


    Please Login or Register  to view this content.
    thanks!
    Last edited by JBeaucaire; 11-26-2013 at 07:16 PM. Reason: Added missing CODE tags. Please read the Forum Rules, link above in the menu bar.

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

    Re: Copy Sheets and Rename

    Your use of ON ERROR RESUME NEXT is why you don't know when/where it fails. Only use that when you're done designing your code and you know it's bulletproof. You're basically telling the macro to barrel on ahead when something doesn't work. So take that out and you'll see when/where it fails, can DEBUG and hover your mouse over variables of the failed line of code to see the current values.

    I would guess that the filenames are not 100% accurate and 4 are not being found. Could be a hidden space in the real filenames or in the cells with the filenames.
    _________________
    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!)

+ 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 - Copy and Rename New Sheets from List - Loop until complete
    By rskinner1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2013, 07:11 AM
  2. Copy & rename sheets across multiple workbooks into one master.
    By CapnSef in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-25-2012, 03:58 AM
  3. Copy sheets and rename from a list
    By foneexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-23-2009, 11:46 AM
  4. Copy sheets to new file and rename it
    By Jokacave in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2007, 08:33 AM
  5. copy and rename sheets
    By Maxjohnson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2007, 12:01 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