+ Reply to Thread
Results 1 to 5 of 5

give a different name when adding a new workbook

  1. #1
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    give a different name when adding a new workbook

    Hi

    I have a macro which copies cells, adds a new workbook, and pastes into it.

    But when it adds a workbook, it is named iex "Book1". If I have been working in excel it may happen that the book added is called "Book 2, 3, 4 and so on. Which makes it difficult to referr to the book. Is it possible to set the name given as prefix? for example Temporary. Without having the whole save as scenario etc..
    Last edited by Hjahren; 09-29-2010 at 08:40 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: give a different name when adding a new workbook

    Easiest way is to assign the new workbook to a variable that you can then work with without knowing its name:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: give a different name when adding a new workbook

    thx

    This will work perfect on the first macro which add the workbook.

    But i have other macros which will work with the added workbook. How to I solve this problem?

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: give a different name when adding a new workbook

    If you declare the variable at a module level all the macros within that module can use it.

    Please Login or Register  to view this content.

    Alternatively you can pass it between macros as an argument:

    Please Login or Register  to view this content.

    Dom

  5. #5
    Forum Contributor
    Join Date
    03-09-2010
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    173

    Re: give a different name when adding a new workbook

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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