+ Reply to Thread
Results 1 to 4 of 4

Excel Paste in macros

  1. #1
    Registered User
    Join Date
    04-18-2011
    Location
    Northern California
    MS-Off Ver
    Excel 2010 & Excel 2011
    Posts
    1

    Excel Paste in macros

    I am attempting to set a filter, select the list, clear the filter and then paste the list to another column. I am getting an error "Paste method of Worksheet class failed".

    here's a sample macro of what I am attempting to accomplish.

    Sub paste()
    '
    ' paste Macro
    '

    '
    ' Sets the filter to remove blanks
    ActiveSheet.Range("$A$8:$F$23").AutoFilter Field:=5, Criteria1:="<>"
    Range("E15:E17").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    ' Clears the filter
    ActiveSheet.Range("$A$8:$F$23").AutoFilter Field:=5
    Range("F9").Select
    ActiveSheet.paste
    End Sub

    Any help would be much appreciated...

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: Excel Paste in macros

    Try doing the paste before you remove the filter.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: Excel Paste in macros

    This macro will copy constant values from column E ... leaving behind blanks or any cell that does not have a constant

    Please Login or Register  to view this content.
    Last edited by nimrod; 04-18-2011 at 04:06 PM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,484

    Re: Excel Paste in macros

    I just noticed that your macro is called Paste. You shouldn't use that because it is a reserved word ... and is probably the cause of the error message.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1