Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Select method failed - Error 400

The following code generates an error in Line 5

Sheets("APR").Select
Rows("9:9").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Data").Select
Rows("25:25").Select ' Line 5 - Error happens here
Selection.Copy
Sheets("APR").Select
ActiveSheet.Paste

The error code is 400. The error description is "Select method
of Range class failed". I'm not sure why this error is occurring,
especially since the above code was generated by Excel's
"Record Macro" function.

Why would the above code work during "Record Macro",
but it generates an error when I run it from VBA code?
I basically have a button on my "APR" spreadsheet that calls
the above code.

Anybody know what's going on here?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Select method failed - Error 400

Hi Robert,

Am Sat, 6 Apr 2013 13:43:24 -0700 schrieb Robert Crandal:

Sheets("APR").Select
Rows("9:9").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Data").Select
Rows("25:25").Select ' Line 5 - Error happens here
Selection.Copy
Sheets("APR").Select
ActiveSheet.Paste


you only can select on a active sheet. But you can write your code
without "Select" and "Selection".
Try:

Sheets("APR").Rows("9:9").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Data").Rows("25:25").Copy _
Sheets("APR").Range("A9")


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Select method failed - Error 400

"Claus Busch" wrote

you only can select on a active sheet. But you can write your code
without "Select" and "Selection".
Try:

Sheets("APR").Rows("9:9").Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Data").Rows("25:25").Copy _
Sheets("APR").Range("A9")


Works great. Thanks yet again! 8)



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
Select method of Range class failed error message Jacob Skaria Excel Programming 0 May 1st 09 07:04 AM
error - select method failed - (columns.select) PBcorn Excel Programming 3 May 19th 08 10:49 AM
Excel VBA error - Select method of Range class failed R Ormerod Excel Programming 0 July 12th 07 09:02 PM
Error: method 'select' of object_worksheet' failed Carl Excel Discussion (Misc queries) 4 September 9th 06 08:52 PM
RT Error 1004, Select method of worksheet class failed Dana Sherbondy Excel Programming 2 October 1st 04 03:55 PM


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

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

About Us

"It's about Microsoft Excel"