+ Reply to Thread
Results 1 to 10 of 10

Varible worksheet names in formulas

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

    Varible worksheet names in formulas

    I am building a workbook used for Work orders, Quotes and Invoicing. I am using VBA to copy 3 worksheets called Order, Quote and Invoice and rename them with the customer name which is entered in a specific cell. So if I enter RRR in the cell and run the macro I get 3 new worksheets called RRR Order, RRR Quote and RRR Invoice. This is all done within the same workbook.
    Quote and Invoice are populated by what is entered in Order. My problem is when the new worksheets are created with the new names the formulas in RRR Quote and RRR Invoice are still referenced to Order. I need them to be referenced to RRR Order. Is there any way to do this?

    I would be grateful any help at all on this

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,754

    Re: Varible worksheet names in formulas

    Maybe do a global replace of Order to RRR Order?


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,653

    Re: Varible worksheet names in formulas

    check this in a sheet where formulas are to be adjusted:
    Please Login or Register  to view this content.
    If it works as expected instead of constant strings like
    Please Login or Register  to view this content.
    - construct your own like:
    Please Login or Register  to view this content.

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

    Re: Varible worksheet names in formulas

    Hi Kaper
    I tried the first code and ran it and it made no changes at all. Any thoughts?

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,653

    Re: Varible worksheet names in formulas

    First idea: attachment
    (because on the file I prepared myself works flawlesly)

    Of course no delicate data (may be alnost no data and just few formulas).

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

    Cool Re: Varible worksheet names in formulas

    Hi Kaper
    Please see attached sheet
    On home page if you click new yearly lease order button it will copy the three sheets Yearly Lease Order, Yearly Quote and Yearly Invoice and rename them with the addition of the contents of Home Page (B4)
    So what I need is for the formulas in the newly created Test Yearly Quote Form in cells B15:F41 to reference worksheet Test Yearly Lease Order instead of Yearly Lease Order
    The same for Test Yearly Invoice Form cells B18:L28 to reference Test Yearly Invoice form instead of Yearly Invoice form.

    So I will generate new 3 sheets for each customer with a new name.

    Does that make any sense?:
    Attached Files Attached Files

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,754

    Re: Varible worksheet names in formulas

    Kaper's modified code for your example:

    Please Login or Register  to view this content.

    Regards, TMS

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,653

    Re: Varible worksheet names in formulas

    As you probably want to replace all references (i.e. in test YQF from YQF to test YQF, and from YLO to test YLO ... and in next sheet again, the way to incorporate my proposition into your macro could be:

    Please Login or Register  to view this content.
    as you see the cruicial code is again basically the same:
    Please Login or Register  to view this content.

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

    Re: Varible worksheet names in formulas

    Hello
    When I run the above code from Kaper I now get an "Update Values" prompt. Can anyone help?
    Attached Files Attached Files
    Last edited by rikk1965; 12-20-2013 at 06:12 AM.

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

    Re: Varible worksheet names in formulas

    Hello
    When I run the above code from Kaper I now get an "Update Values" prompt. Can anyone 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. Replies: 0
    Last Post: 11-07-2011, 11:54 AM
  2. worksheet names in formulas
    By obrien2010 in forum Excel General
    Replies: 3
    Last Post: 04-23-2010, 06:19 PM
  3. name worksheet by usıng a varible
    By stevekirk in forum Excel General
    Replies: 1
    Last Post: 08-24-2006, 11:52 PM
  4. Controls names as varible?
    By lily in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2006, 04:15 PM
  5. Using worksheet names in formulas
    By WightRob in forum Excel General
    Replies: 2
    Last Post: 08-07-2005, 02:17 PM

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