range("a1").select not working

  • Thread starter Thread starter tkaplan
  • Start date Start date
T

tkaplan

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. th
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
 
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.
 
thank you dave. You're right (again). CT summary does not own tha
code. I moved the code to a macro and called the macro and now i
works:)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top