+ Reply to Thread
Results 1 to 10 of 10

Code to set workbook name (dynamic)

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Code to set workbook name (dynamic)

    Hi,

    Is there a way in which I can get the “Set Workbooks name” to come from a cell value within excel, instead of setting the filename from the vba code as shown below:

    I want the operator to not have to go into the code, so entering the name in a sheet is preferred then running a macro is preferred.


    Example code:

    Please Login or Register  to view this content.

    Many thanks in advance.
    Tom.
    Last edited by tompee29; 04-27-2017 at 05:05 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code to set workbook name (dynamic)

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    If posting code please use code tags, see here.

  3. #3
    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,464

    Re: Code to set workbook name (dynamic)

    Awaiting code tags to be added.
    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


  4. #4
    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,464

    Re: Code to set workbook name (dynamic)

    @Norie: apologies, I didn't refresh the thread.

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Code to set workbook name (dynamic)

    sorted, apologies for that

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code to set workbook name (dynamic)

    Which workbook do you want to refer to based on the value in a cell?

    How many workbooks are open when you run the code?

    Which workbook is the code in?

  7. #7
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Code to set workbook name (dynamic)

    Hi,

    Ok, there's three workbooks altogether.

    Control Workbook (DWOR Duplicator.xlsm, This contains all the code)

    The Source Workbook is called DWOR Line 5 Week 15 Old .xlsm
    The Destination Workbook is called DWOR Line 5 Week 15 2017.xlsm

    The source and destination files are merely slave files and do not run any code, I basically need the source to duplicate specific ranges into the destination.

    The aim is to have a nice frontend that a novice user can type the "week number" into say Cell "A1" and then click "run".

    Cell A1 would then dynamically be pulled in by the code.

    At the moment a novice would have to go into my code below and change the Week number to the latest Week number, i.e. Week 15 to Week 16.

    Please Login or Register  to view this content.
    Hope this makes sense

    Thanks,

    Tom.
    Last edited by tompee29; 04-27-2017 at 05:44 AM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code to set workbook name (dynamic)

    Why don't you use an inputbox?

    Something like this perhaps.
    Please Login or Register  to view this content.
    PS I'm assuming the source and destination workbooks are open.

    PPS If they are open there could be other ways to refer to them, might not even need user input.

  9. #9
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Code to set workbook name (dynamic)

    Hmmm,

    I like it. I didn't think of that route.

    I'll get back to you and let you how I get on.

    Thanks for your help Norie.

    Tom.

  10. #10
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Code to set workbook name (dynamic)

    Hi Norie,

    Your code was really helpful, I made a change though which now makes it do exactly what I originally wanted.

    I substituted your input box request to get the wkNum, with the code: wkNum = Sheets("Start").Range("D8").Value.

    Please Login or Register  to view this content.
    Thanks again for your help

    Regards,

    Tom.
    Last edited by tompee29; 04-28-2017 at 05:34 AM.

+ 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: 2
    Last Post: 12-28-2015, 08:30 AM
  2. [SOLVED] VBA Code to export dynamic excel tabs to new workbook
    By savetrees in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-18-2014, 12:25 PM
  3. [SOLVED] Very Complicated Code to Copy dynamic data from one workbook to other workbooks
    By mannuhs in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-30-2013, 02:22 PM
  4. vb6 code to copy cell value from one workbook to another and it should be dynamic
    By sidhemu in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-08-2013, 10:23 AM
  5. VBA Code to insert dynamic data from sperate workbook to chart
    By Policeme21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 04:33 PM
  6. Creating Dynamic Folders/WorkBook from a Sheet with Dynamic Path.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 03-28-2011, 05:42 AM
  7. Code creates new workbook-> code to automatically run a set code on that workbook
    By cwalker6 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2009, 08:00 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