Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selection.Copy throws an Object Required error

When I try and copy a selection of cells my code throws the following code

Runtime Error 424: Object Required

Any Ideas? Here is part of my code

For a = 1 To ACount
mainworkbook.Activate
Sheets("List").Cells(a*20, 1).Select
Range(ActiveCell, ActiveCell.Offset(-19, 5)).Select
Selection.Copy ' THIS IS WHERE THE ERROR OCCURS
secondaryworkbook.Activate
Sheets(a).Cells(1, 1).Select
Selection.Paste
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Selection.Copy throws an Object Required error

Hi,

you don't need to select the range to copy/paste... I think this code would
also do the same thing as your code:

For a = 0 To ACount - 1
Set rngCopy = mainworkbook.Worksheets("List").Cells(1, 1).Offset(a * 20)
rngCopy.Resize(20, 5).Copy
Destination:=secondaryworkbook.Worksheets(CStr(a + 1)).Cells(1, 1)
Next a



--
Hope that helps.

Vergel Adriano


"the00snoopy" wrote:

When I try and copy a selection of cells my code throws the following code

Runtime Error 424: Object Required

Any Ideas? Here is part of my code

For a = 1 To ACount
mainworkbook.Activate
Sheets("List").Cells(a*20, 1).Select
Range(ActiveCell, ActiveCell.Offset(-19, 5)).Select
Selection.Copy ' THIS IS WHERE THE ERROR OCCURS
secondaryworkbook.Activate
Sheets(a).Cells(1, 1).Select
Selection.Paste
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Selection.Copy throws an Object Required error

Thanks. I had to take out the CStr command so that the line was

Destination:=secondaryworkbook.Worksheets(a + 1).Cells(1, 1)

before it would work but after that it worked great.

Just for furture refrence does anybody know why I had error before?

"Vergel Adriano" wrote:

Hi,

you don't need to select the range to copy/paste... I think this code would
also do the same thing as your code:

For a = 0 To ACount - 1
Set rngCopy = mainworkbook.Worksheets("List").Cells(1, 1).Offset(a * 20)
rngCopy.Resize(20, 5).Copy
Destination:=secondaryworkbook.Worksheets(CStr(a + 1)).Cells(1, 1)
Next a



--
Hope that helps.

Vergel Adriano


"the00snoopy" wrote:

When I try and copy a selection of cells my code throws the following code

Runtime Error 424: Object Required

Any Ideas? Here is part of my code

For a = 1 To ACount
mainworkbook.Activate
Sheets("List").Cells(a*20, 1).Select
Range(ActiveCell, ActiveCell.Offset(-19, 5)).Select
Selection.Copy ' THIS IS WHERE THE ERROR OCCURS
secondaryworkbook.Activate
Sheets(a).Cells(1, 1).Select
Selection.Paste
Next

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
Error 424 : Object required vivmaha Excel Programming 3 June 1st 07 02:11 AM
Object required error... IT_roofer Excel Programming 7 April 12th 07 06:36 PM
Error: Object required Stuart[_21_] Excel Programming 2 September 29th 05 09:07 AM
Object required error broogle Excel Programming 7 March 21st 05 09:01 AM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 02:03 AM.

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"