![]() |
How to use the "Range" object
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 |
How to use the "Range" object
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. -- Regards from Virginia Beach, Earl Kiosterud www.smokeyl.com ----------------------------------------------------------------------- "Jeff" wrote in message ... 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 |
How to use the "Range" object
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 "Jeff" wrote in message ... 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 |
How to use the "Range" object
I tried
Set tRange = Sheets("Iinforce").Range("A1") tRange.Activate also but that didnt work. "Earl Kiosterud" wrote: 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. -- Regards from Virginia Beach, Earl Kiosterud www.smokeyl.com ----------------------------------------------------------------------- "Jeff" wrote in message ... 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 |
How to use the "Range" object
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 ----------------------------------------------------------------------- "Earl Kiosterud" wrote in message ... 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. -- Regards from Virginia Beach, Earl Kiosterud www.smokeyl.com ----------------------------------------------------------------------- "Jeff" wrote in message ... 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 |
How to use the "Range" object
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 wrote: 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 -- Dave Peterson |
How to use the "Range" object
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 ----------------------------------------------------------------------- "Jeff" wrote in message ... I tried Set tRange = Sheets("Iinforce").Range("A1") tRange.Activate also but that didnt work. "Earl Kiosterud" wrote: 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. -- Regards from Virginia Beach, Earl Kiosterud www.smokeyl.com ----------------------------------------------------------------------- "Jeff" wrote in message ... 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 |
All times are GMT +1. The time now is 09:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com