+ Reply to Thread
Results 1 to 2 of 2

How to select a sheet

  1. #1
    Registered User
    Join Date
    05-11-2005
    Posts
    12

    How to select a sheet

    In the program that I am working on, there is an error when the program tries to select a sheet. The code goes like this:

    Sheets(dataSheet).select
    and dataSheet is a valid sheet. I can't figure this out, what is going on, why is this an error?

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    do you have more than 1 workbook open.

    if yes then the active workbook is not the workbook that has the required sheet in it.


    try using

    workbooks("book1").Sheets(dataSheet).select

    or

    thisworkbook.Sheets(dataSheet).select

    Note:- Your macro will run quicker if you do not select workbooks, sheets, ranges etc.

    you can yose code like
    workbooks("book1").Sheets(dataSheet)..range("a1")="Hi"

+ 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