Results 1 to 8 of 8

Runtime error PasteSpecial method of Range class failed

Threaded View

russ50 Runtime error PasteSpecial... 12-17-2012, 09:28 PM
AlphaFrog Re: Runtime error... 12-17-2012, 10:27 PM
russ50 Re: Runtime error... 12-17-2012, 11:17 PM
AlphaFrog Re: Runtime error... 12-17-2012, 11:31 PM
russ50 Re: Runtime error... 12-17-2012, 11:58 PM
  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Runtime error PasteSpecial method of Range class failed

    Help would be appreciated to resolve intermittentt runtime error, code fails at PasteSpecial. I would like to understand the error and not just a fix.
    Any help to the issue would be great.

    Set xlApp = New Excel.Application 'opens new instance
    Set xlBook = xlApp.Workbooks.Open("c:\temp\inventory")
    Set xlSheet = xlBook.Worksheets("Sheet1")
    Set oRange = xlSheet.Columns(1)

    Set aCell = oRange.Find(What:=MyName, LookIn:=xlValues, LookAt:=xlWhole, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
    If Not aCell Is Nothing Then
    firstName = aCell.Address

    Do
    nextRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
    aCell.Resize(, 4).Copy
    ActiveSheet.Cells(nextRow, 1).PasteSpecial Paste:=xlValues
    Application.CutCopyMode = False
    Set aCell = oRange.FindNext(aCell)
    Loop While Not aCell Is Nothing And aCell.Address <> firstName
    Application.Quit
    End If
    End Sub
    Last edited by russ50; 12-18-2012 at 12:46 AM. Reason: Issue solved

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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