Results 1 to 6 of 6

Why must I specify workbook here?

Threaded View

  1. #1
    Forum Contributor terrypin's Avatar
    Join Date
    01-06-2010
    Location
    East Grinstead, UK
    MS-Off Ver
    MS Office 365
    Posts
    533

    Why must I specify workbook here?

    I'm stepping through very basic VBA to re-learn some essentials.

    I have two workbooks open, each with a couple of worksheets. No duplicate names. The two open sheets are called Track Data and TEMP respectively.

    Why does this fail with subscript out of range please?

    Worksheets("Track Data").Activate
    It works if I specify the workbook.

    Workbooks("TEST track sheet copying.xlsm").Worksheets("Track Data").Activate
    That involves finding its name and carefully pasting it into my code, so I'd prefer not to do so. Why must I specify it in this situation please? In what circumstances can it be left out?

    Terry, East Grinstead, UK
    Last edited by zbor; 03-03-2017 at 06:01 AM.
    Terry, East Grinstead, UK
    Excel 365, Win 10 Pro, i7 PC, 4.0 GHz

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Assign name to Workbook, Copy range from one workbook to another workbook
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2015, 03:40 AM
  2. [SOLVED] VBA to open new workbook and run macro from new workbook, which closes old workbook
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2014, 10:45 AM
  3. [SOLVED] Code to cut cell from one workbook, close same workbook, and paste in different workbook
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 03-13-2014, 04:01 PM
  4. Copy data one workbook to another workbook without opening workbook
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2014, 11:28 AM
  5. [SOLVED] Copy Values From Each Workbook in Folder to a Single Sheet in New Workbook +Workbook names
    By Arsham24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:42 PM
  6. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM
  7. Replies: 1
    Last Post: 04-01-2006, 03:50 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