+ Reply to Thread
Results 1 to 3 of 3

Create new workbook, then REFERENCE it, Excel 2013

  1. #1
    Registered User
    Join Date
    06-04-2012
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Question Create new workbook, then REFERENCE it, Excel 2013

    Surely I'm missing something simple! A colleague made a macro that would work in 2003, 2007, and 2010, but it doesn't work in 2013. I decided to start from scratch, because I want to learn. I recorded a macro to learn how to create a new workbook with 3 named sheets, which works fine. Now I want to copy and paste values into this new sheet, to provide lightweight workbooks for reading on an iPhone, so no bogging down with macros and databases.

    Whatever I try, I get error 9, subscript out if range. I've searched and searched, but everything I find is instructions for referencing named workbooks. That's fine, but Excel names them Book 1, Book 2, etc, and I can't control how many workbooks are open or even how many are going to be made that day.

    There has to be a simple command to activate the new workbook that you just created, and switch back and forth.

    I don't want to save the new workbook, since the file structure is different under Vista, 7, and 8, but I would like to name it if I could.

    If it works in 2003, 2010, and 2013, that would be a bonus, but I don't really need 2003 - that's going to disappear along with our XP machines in April.

  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: Create new workbook, then REFERENCE it, Excel 2013

    You can create a new workbook, and a reference to it like this.
    Please Login or Register  to view this content.
    The reference, wbNew in this example, can then be used to refer to the workbook in the rest of the code.

    Not quite sure about the not saving part.

    You can't do much with an unsaved workbook and that includes naming it.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-04-2012
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Create new workbook, then REFERENCE it, Excel 2013

    That's how it was before, but an unnecessarily complicated way of copying the existing names was what was broken, and my cack-handed attempts to fix it was resulting in two new workbooks, which was causing the problem. You set me on the right track though, and it's all working now. Thanks for your 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. Recording Macro to create a Pivot Table in Excel 2013: run time error 5 invalid procedure
    By developerstew in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2013, 07:17 AM
  2. Windows 8, Excel 2013 and Project 2010 - Reference Error in Macro
    By microsoftexcel007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 06:23 PM
  3. Automatically transfer data from one sheet to another in a workbook - Excel 2013
    By WGBarry in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2013, 01:03 PM
  4. Replies: 3
    Last Post: 03-29-2013, 12:35 PM
  5. [SOLVED] copy active sheet, create new workbook, name new workbook based on cell reference
    By jm0392 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-20-2012, 07:12 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