ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   What's wrong with this vb? (https://www.excelbanter.com/excel-worksheet-functions/14773-whats-wrong-vbulletin.html)

DaveMoore

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

Bob Phillips

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




DaveMoore

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




All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com