How to use the "Range" object

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi,

I was trying to copy stuff but I am getting an error.

Set tRange = Sheets("Iinforce").Range("A1")
tRange.Select

Error = "Selection method of range class failed"

Why is this an error when you can legally tye Range("A1").select?
Isn't my code the same thing?

Thanks for your help
 
Jeff,

It may be that sheet "linforce" isn't the active sheet at the time. Every sheet has
selected cells, and an active (the white) cell, but you have to explicitly activate the
sheet containing the cell you wish to select. I think the Range("A1") doesn't fail because
it selects A1 of the active sheet, whatever it happens to be.
 
Jeff,

I don't know for sure, but I don't think you can select a cell on a sheet
that is not active. Because you have the range qualified with a sheet, I'm
guessing that the Iinforce sheet is not active.

Activate the sheet first, then select the cell.

Set tRange = Sheets("Iinforce").Range("A1")
Sheets("Iinforce").Activate
tRange.Select

See if that will work.

HTH,

Conan
 
I tried

Set tRange = Sheets("Iinforce").Range("A1")
tRange.Activate

also but that didnt work.
 
Jeff,

Also, make sure that you've dimmed tRange as a Range object.

Dim tRange as Range
--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeyl.com
-----------------------------------------------------------------------
 
with sheets("iinforce")
.select
set trange = .range("a1")
trange.select
end with

You can only select a range on the activesheet.

Another alternative:
Set tRange = Sheets("Iinforce").Range("A1")
application.goto tRange ', scroll:=true '????
 
Jeff,

The issue is which sheet is active at the time you try to activate or select tRange.. It
must be linforce" for it to work.

Dim tRange As Range

Set tRange = Sheets("linforce").Range("A1")
Sheets("linforce").Activate
tRange.Activate

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeyl.com
-----------------------------------------------------------------------
 

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