Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Activesheet.Paste method gives error

  Asked By: Harley    Date: Jan 11    Category: MS Office    Views: 1742
  

I am encountering an error while running my code, the function which the code
performs is... it applies filter on the data through the parameters provided by
the user, it then copies 1 set of data at a time to a different workbook till
all the parameters are run. The below metioned code gives an error in
'Activesheet.Paste', the odd thing is that it pastes the data as required and
then gives the error..


Sheets(myDataSheet).Select

Rows("1:1").Select

Selection.Insert Shift:=xlDown

Cells.Select

Selection.AutoFilter Field:=splitbycol, Criteria1:=insidearr(j)

CSVDate = GetDateDifference(RDate)

CSVName = insidearr(j) & " " & CSVDate & ".csv"

Sep = "|"

Workbooks.Add

Set wkbook1 = ActiveWorkbook

wkbook.Activate

Selection.Copy

wkbook1.Activate

ActiveSheet.Range("A1").Select

ActiveSheet.Paste

Rows("1:1").Select

Rows("1:1").Delete

Is there a workaround to this problem.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Shelia Wells     Answered On: Jan 11

I think the issue is that you are pasting to the whole of the active sheet.
Try replacing "activesheet.paste" with "selection.paste"

 
Answer #2    Answered By: Roop Kapoor     Answered On: Jan 11

I tried using Selection.Paste, but it gives me same error. Any other advise?
Does applying filter  and then copying and pasting to another workbook  could be a
problem? Because the Activesheet.Paste is used for another report which does not
require applying a filter works fine.

 
Answer #3    Answered By: Abasi Massri     Answered On: Jan 11

Have you tried recording a macro that does this and see what the differences
are?
I'm sure you've got lots of code  that you didn't include here.
Like: I don't see where you've saved wkbook, or RDate.
Also, if you're using Rows(1,1).delete
you don't need to do Rows(1,1).select...
Because, Rows(1,1).Delete is actually a combination of two commands:
Rows(1,1).Select
Selection.Delete
I'd start with recording the macro, and see if the recorded macro gives the same
result.
If it does not, compare the two and see how they differ...

 
Didn't find what you were looking for? Find more on Activesheet.Paste method gives error Or get search suggestion and latest updates.




Tagged: