+ Reply to Thread
Results 1 to 12 of 12

VBA to replace new name of worksheets in formulas in newly copied worksheets

  1. #1
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    VBA to replace new name of worksheets in formulas in newly copied worksheets

    On the attached worksheet on "Home Page" I enter the client name on cell B4 and click the command button below it. This copies worksheets "Yearly Lease Order", "Yearly Quote Form" and "Yearly Invoice Form" and adds the contents of worksheet "Home Page" cell B4 to the copied worksheets names. ie if "Test" is in B4 then the new worksheets are called "Test Yearly Lease Order", "Test Yearly Quote Form" and "Test Yearly Invoice Form". The problem is the formulas in the new worksheets "Test Yearly Quote Form" and "Test Yearly Invoice Form" are still referencing "Yearly Lease Order". I need them to look at the newly created "Test Yearly Lease Order". Somehow I need to run a replace on "Test Yearly Quote Form" and "Test Yearly Invoice Form" to replace "Yearly Lease Order" with the contents of "Home Page" cell B4 & "Yearly Lease Order" I would like this happen with the same initial click of the command button.
    Any Ideas anyone?????
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Do a find and replace Yearly to Test, should work on the forumla to.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    I need this to be part of the macro that I'm running and I dont know how to make it work with VBA

    Here is the code:

    Please Login or Register  to view this content.
    Last edited by rikk1965; 12-31-2013 at 05:15 AM. Reason: Adding Code Tags

  4. #4
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Is there any one that can help me with this thread. I posted before Christmas and still havent found a solution. Spreadsheet is attached and explination on top of thread

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    rikki1965,
    We can help, but first you need to follow forum's rule.
    Please wrap you code with code tags.
    You need to edit post #3 and use code tags.

  6. #6
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Hello

    I do apologise. I'm new to the forum and learning. Code Tags have been added to the code in post 3. Any help with this will be much appreciated.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Okay!
    Could you please explain what are you trying to do. It is not clear from post 1.
    I know your code has WorkSheetExists, so you are testing for the existence of a tab.

  8. #8
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Sure
    On the Home Page tab I enter a customer's name in cell B4. When I hit the command button below that the code in post 3 copies worksheets "Yearly Lease Order", "Yearly Quote Form" and "Yearly Invoice Form" and pastes them in three new tabs and ads the customer name in Home Page B4 to the tab name. This works great. There are formulas in "Yearly Quote Form" and "Yearly Invoice Form" that look at cells in "Yearly Lease Order". When the new sheets are created with their new names in the tabs they are still looking at the original "Yearly Lease Order" instead of the newly created "Yearly Lease Order" with the customers name added. So in other words the original 3 worksheets are a template of sorts and the formulas work within that group. When a new set of three is created from the template they need to work as a new group with the formulas only looking at that group. Can this be done with a search and replace text or is there a more efficiant way. Make any sense?

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    Well,
    When I run the code, I get an error on the function code.
    If you are copying the 3 sheets and want to copy the formulas in to new sheets, you need to copy the formulas too.
    I think your code is probably coping values only.

  10. #10
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    I tried downloading the worksheet from post 1 and it worked fine for me. Ive tried adding this extra code to module 1 and it starts to work but then I get Update Values Prompt.
    If I keep hitting the Esc button it goes through line by line and replaces the text as I want it to do. How can I get it to stop the Update value prompt and just running the code?

    Please Login or Register  to view this content.
    See attached pdf for Update Value Prompt
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    I do not know if this happens when a formula is linked to an outside source, but if it is a code, you can suppress the alerts and break the link.

  12. #12
    Registered User
    Join Date
    12-16-2013
    Location
    Reading, England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA to replace new name of worksheets in formulas in newly copied worksheets

    yes that works
    Ive supressed the alerts

    Thanks for you help

+ 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. Worksheets from source to replace worksheets in the destination workbook when closed
    By anushatamby in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2013, 03:52 PM
  2. Replies: 9
    Last Post: 12-19-2012, 01:32 PM
  3. Dynamic array in VBA of newly added worksheets
    By greglittle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 06:00 PM
  4. [SOLVED] Copied worksheets not protected
    By Shahid_Excel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2012, 11:02 AM
  5. Linking Newly Created Worksheets
    By bpowers in forum Excel General
    Replies: 0
    Last Post: 02-15-2009, 11:25 AM

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