Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
DaveMoore
 
Posts: n/a
Default What's wrong with this vb?

I am running excel2002 on Windows xp and dabbling in the writing of macros.
Can anyone tell me what is wrong with this?

'rem Copy the duplicated record to Archive and delete
Dim delcell As Range
Dim myRange As Range
Dim copyToRange As Range

Set copyToRange = Range("Archive!C12")
Set myRange = Range("dup")
Set delcell = myRange.Find(What:=1, LookIn:=xlValues, LookAt:=xlWhole)
If Not delcell Is Nothing Then
With delcell.EntireRow
Intersect(.Cells, Range("C:DC")).Copy Destination@ = copyToRange
.Delete
End With
End If

I get the following error message at the line that begins "Intersect..."
Run Time Error '1004'
Copy method of Range class failed.

Any help gratefully received
Dave Moore
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Try

Intersect(.Cells, Range("C:DC")).Copy Destination:=copyToRange


--

HTH

RP
(remove nothere from the email address if mailing direct)


"DaveMoore" wrote in message
om...
I am running excel2002 on Windows xp and dabbling in the writing of

macros.
Can anyone tell me what is wrong with this?

'rem Copy the duplicated record to Archive and delete
Dim delcell As Range
Dim myRange As Range
Dim copyToRange As Range

Set copyToRange = Range("Archive!C12")
Set myRange = Range("dup")
Set delcell = myRange.Find(What:=1, LookIn:=xlValues, LookAt:=xlWhole)
If Not delcell Is Nothing Then
With delcell.EntireRow
Intersect(.Cells, Range("C:DC")).Copy Destination@ = copyToRange
.Delete
End With
End If

I get the following error message at the line that begins "Intersect..."
Run Time Error '1004'
Copy method of Range class failed.

Any help gratefully received
Dave Moore



  #3   Report Post  
DaveMoore
 
Posts: n/a
Default

DOH!!!
Thank you Bob. I couldn't see the wood for the trees.
The macros works.

Bob Phillips wrote:
Try

Intersect(.Cells, Range("C:DC")).Copy Destination:=copyToRange


--

HTH

RP
(remove nothere from the email address if mailing direct)


"DaveMoore" wrote in message
om...
I am running excel2002 on Windows xp and dabbling in the writing of

macros.
Can anyone tell me what is wrong with this?

'rem Copy the duplicated record to Archive and delete
Dim delcell As Range
Dim myRange As Range
Dim copyToRange As Range

Set copyToRange = Range("Archive!C12")
Set myRange = Range("dup")
Set delcell = myRange.Find(What:=1, LookIn:=xlValues,

LookAt:=xlWhole)
If Not delcell Is Nothing Then
With delcell.EntireRow
Intersect(.Cells, Range("C:DC")).Copy Destination@ =

copyToRange
.Delete
End With
End If

I get the following error message at the line that begins

"Intersect..."
Run Time Error '1004'
Copy method of Range class failed.

Any help gratefully received
Dave Moore


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
I get wrong dates when i paste from a different sheet into a new s mmollat Excel Discussion (Misc queries) 2 January 6th 05 07:35 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM
multi-level subtotals are in the wrong position Worksheet Guru need Excel Worksheet Functions 1 December 6th 04 05:22 PM
Logic statement returns wrong answer. Tony Excel Worksheet Functions 2 December 2nd 04 05:07 AM
IF function displays wrong amount JAnderson Excel Worksheet Functions 4 November 6th 04 06:41 PM


All times are GMT +1. The time now is 11:20 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"