Copy data range quickly

BigDelGooner

Board Regular
Joined
Aug 17, 2009
Messages
197
Hi there

I am trying to use the .copy destination:= method to copy a data range from one worksheet to another but I am getting an 'Application-defined or object-defined error'. When I use this method copying just one cell its fine but doesn't seem to like copying the range. Is there something wrong with the following:

Sheets("LOCKED_SecList").Range(Cells(Start_Row, Start_Column), Cells(End_Row, End_Column)).Copy Destination:=Sheets("VIEW_NoDetails").Range(Cells(Start_Row, Start_Column), Cells(End_Row, End_Column))

Really appreciate any help guys...
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hello BigDelGooner,

When working with Ranges in VBA, if the Range object you are working with (Range or Cells) isn't qualified, it is assumed you mean the Range or Cells on the ActiveSheet.

I make it a habit of using Range object variables in my code to help eliminate this problem and it make more flexible. Here is an example. You should dimension your variables to help eliminate problems also.

Rich (BB code):
Sub CopyTest()

    ' Thread: http://www.mrexcel.com/forum/showthread.php?t=624451
    
    Dim DstWks As Worksheet
    Dim EndColumn As Long, EndRow As Long
    Dim StartColumn As Long, StartRow As Long
    Dim SrcWks As Worksheet
    
        StartRow = 1
        StartColumn = 1
    
        EndRow = 10
        EndColumn = 1

        Set SrcWks = Sheets("LOCKED_SecList")
        Set DstWks = Sheets("VIEW_NoDetails")
    
        SrcWks.Range(SrcWks.Cells(StartRow, StartColumn), SrcWks.Cells(EndRow, EndColumn)).Copy _
        DstWks.Range(DstWks.Cells(StartRow, StartColumn), DstWks.Cells(EndRow, EndColumn))
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top