Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CDM CDM is offline
external usenet poster
 
Posts: 2
Default Select method failing

I'm trying to remove a header row in a different spreadsheet with the
following code. Everything goes OK until it gets to .Range("A1").select. It
gives me an error message that says, "Select method of Range class failed."
What am I missing?

Dim objWkBook As Object
Dim objWkSheet As Object

Set objWkBook = GetObject("Z:\AgingByLocation.xls")
Set objWkSheet = objWkBook.Worksheets(1)
With objWkSheet
.Activate
.Rows(1).Delete Shift:=xlUp
.Range("A1").Select
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Select method failing

You are trying to activate a cell which is not opened...If you are looking to
select a range then try the below code which opens the workbook..

Dim objWkBook As Workbook
Dim objWkSheet As Worksheet

Set objWkBook = Workbooks.Open("c:\3.xls")
Set objWkSheet = objWkBook.Worksheets(1)
With objWkSheet
.Activate
.Rows(1).Delete Shift:=xlUp
.Range("A1").Activate
End With
objWkBook.Close

--
Jacob


"CDM" wrote:

I'm trying to remove a header row in a different spreadsheet with the
following code. Everything goes OK until it gets to .Range("A1").select. It
gives me an error message that says, "Select method of Range class failed."
What am I missing?

Dim objWkBook As Object
Dim objWkSheet As Object

Set objWkBook = GetObject("Z:\AgingByLocation.xls")
Set objWkSheet = objWkBook.Worksheets(1)
With objWkSheet
.Activate
.Rows(1).Delete Shift:=xlUp
.Range("A1").Select
End With

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy method of object failing vj2india Excel Programming 0 April 20th 06 02:21 AM
Select Method Failing cmk18[_8_] Excel Programming 2 July 11th 05 11:53 PM
Publish method failing, can't understand why Mark Excel Programming 0 June 22nd 05 07:52 PM
select method of range class failing ? mark kubicki Excel Programming 6 April 21st 05 05:38 PM
add method of validation failing mark kubicki Excel Programming 2 April 19th 05 08:08 PM


All times are GMT +1. The time now is 10:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"