+ Reply to Thread
Results 1 to 4 of 4

Excel 2010 Paste Doesn't work twice

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Excel 2010 Paste Doesn't work twice

    I have a simple macro to copy/paste rows into a worksheet. The user clicks a button to add additional rows. If I click it the first time, it works. If I click it the second time, I get this message: "Rutntime 1004: Unable to get the pastespecial quality of the worksheet class". Any help would be much appreciated...thanks!

    Sub CopyBlock()
    
        Sheets("Data").Select
        Range("ToCopy").Select
        Selection.Copy
        Sheets("New").Select
        
        With ActiveSheet
        .Unprotect
    
        Sheets("New").Select
            Cells.Find(What:="EOF", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
            xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False).Activate
        ActiveCell.Offset(-1, 0).Range("A1").Select
        Selection.Insert Shift:=xlDown
        Selection.PasteSpecial .PasteSpecial - 4122
            
        ActiveCell.Offset(1, 0).Select
    
        ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
        End With
    End Sub
    Last edited by Leith Ross; 06-11-2013 at 03:41 PM. Reason: Added Code Tags

  2. #2
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Excel 2010 Paste Doesn't work twice

    why would you want to do that?, the pastespecial pastes the copied cells, not just the values, even if you are only pasting the values. it's not as if they become variables that can be calculated. it looks like you want to paste the value then the value - 4122

    for that you would have to do something different

    is ToCopy a single cell or a range of cells?

  3. #3
    Valued Forum Contributor
    Join Date
    11-20-2012
    Location
    Seattle, WA USA
    MS-Off Ver
    Excel 2010
    Posts
    597

    Re: Excel 2010 Paste Doesn't work twice

    for a cell named ToCopy:

    Sub ToCopy()
    Dim c As Double
    c = Range("ToCopy").Value
    a = c + c - 4122
    With Sheets("New")
    zstart = .Cells.Find(What:="EOF", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Address
    
    .Range(zstart).Offset(-1).Value = a
    
    End With
    
    End Sub

  4. #4
    Registered User
    Join Date
    09-20-2012
    Location
    Cambridge, Ontario
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Excel 2010 Paste Doesn't work twice

    ToCopy is a range of cells.

+ 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