VBA - Paste 1004 Error

stwp86

New Member
Joined
Jun 28, 2012
Messages
19
Hey All . . .

I have used this code before, grabbed it from here (good stuff if you use SSRS):Chintak's Blog - Refreshable SSRS reports in Excel - Chintak Chhapia , and it has always worked swimmingly. I have another use case that requires this trick, but I am repeatedly getting a paste error on the last line. Any thoughts on how I can resolve this issue, see code below. Thanks! Travis

Code:
Sub SessionData()


    Worksheets("Sessions").Activate
    Worksheets("Sessions").Cells.Delete
    Range("A1").Select
    
    
    Dim client As String
    Dim domain As String
    Dim begin As String
    Dim finish As String




    client = "STP_OP"
    domain = "P333"
    begin = "2015/05/18"
    finish = "2015/05/22"
    
    'Sessions Tab
    Workbooks.Open Filename:="http://link&customer=" & client & "&Domain=" & domain & "&BaselineBegin=" & begin & "&BaselineEnd=" & finish & "&rs:Format=CSV"
    ' Select the range to copy from the csv
    Range("A:N").Copy
    'Selection.ClearContents
    Application.DisplayAlerts = False
    ActiveWorkbook.Close SaveChanges:=False
    ' Note:- Name of this file should be same as the file name.
    Windows("macro.xlsm").Activate
    'Copy csv data into this spread sheet at this Range
    Worksheets("Sessions").Range("A1").Select
'    ActiveSheet.Paste
    ActiveSheet.Paste
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,
is the sheet you are pasting to protected? If so you can try this:

change this:

Code:
Worksheets("Sessions").Range("A1").Select
'    ActiveSheet.Paste
    ActiveSheet.Paste

To This:

Code:
With Worksheets("Sessions")
    .Unprotect Password:=""
    .Range("A1").Paste
End With

add password as required.

Hope Helpful

Dave
 
Upvote 0
No, it was not protected. I changed the code to this just now, and it appears to have fixed the issue:

Code:
    Worksheets("Sessions").Range("A:N").Select
    ActiveSheet.Paste

I believe it has something to do with the way Worksheets.Range functions. As, I was selection a range of a:n above I needed to specify the exact range in the paste.

If anyone knows if this is wrong please correct me.
 
Upvote 0
I tried this, but am getting an error, runtime 438, object does not support this property or method
 
Upvote 0

Forum statistics

Threads
1,196,053
Messages
6,013,118
Members
441,749
Latest member
batel19

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