+ Reply to Thread
Results 1 to 4 of 4

range("a1").select not working

  1. #1
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136

    Question range("a1").select not working

    I have a line in my code:

    Sheets("CT Summary").Select
    Range("A1").Select

    when i run my code, the debugger stops at the range.select line. the cell is not hidden, the sheets are not protected.
    the error i get is:
    runtime error 1004: select method of Range class failed.

    i cant figure out what is wrong with this. any suggestions?
    Last edited by tkaplan; 10-27-2005 at 12:05 PM.

  2. #2
    Randall Arnold
    Guest

    RE: range("a1").select not working

    Try this:

    Sheets("CT Summary").Activate
    Activesheet.Range("A1").Select

    Randall Arnold

    "tkaplan" wrote:

    >
    > I have a line in my code:
    >
    > Sheets("CT Summary").Select
    > Range("A1").Select
    >
    > when i run my code, the debugger stops at the range.select line. the
    > cell is not hidden, the sheets are not protected.
    > the error i get is:
    > runtime error 1004: select method of Range class failed.
    >
    > i cant figure out what is wrong with this. any suggestions?
    >
    >
    > --
    > tkaplan
    > ------------------------------------------------------------------------
    > tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
    > View this thread: http://www.excelforum.com/showthread...hreadid=479822
    >
    >


  3. #3
    Dave Peterson
    Guest

    Re: range("a1").select not working

    I'm guessing that this code is behind a worksheet.

    Unqualifed ranges in that kind of module refer to the sheet that owns the code.
    And I'm guessing that "CT Summary" isn't the sheet that owns that code.

    You could use:
    Sheets("CT Summary").Select
    Sheets("CT Summary").range("a1").select

    or
    application.goto Sheets("CT Summary").range("a1"),scroll:=true

    But you don't usually have to select a range to work with it.

    Sheets("CT Summary").range("a1").value = "hi there"

    is one way to assign a value directly to that cell.

    tkaplan wrote:
    >
    > I have a line in my code:
    >
    > Sheets("CT Summary").Select
    > Range("A1").Select
    >
    > when i run my code, the debugger stops at the range.select line. the
    > cell is not hidden, the sheets are not protected.
    > the error i get is:
    > runtime error 1004: select method of Range class failed.
    >
    > i cant figure out what is wrong with this. any suggestions?
    >
    > --
    > tkaplan
    > ------------------------------------------------------------------------
    > tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
    > View this thread: http://www.excelforum.com/showthread...hreadid=479822


    --

    Dave Peterson

  4. #4
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    thank you dave. You're right (again). CT summary does not own that code. I moved the code to a macro and called the macro and now it works

    thank you for the explanation though. I never knew that and it was driving me insane that it wasnt working. but now i know why

+ 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