+ Reply to Thread
Results 1 to 8 of 8

Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

  1. #1
    blork
    Guest

    Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Hi,
    I'm pretty new to working with VB, so excuse me if this is just
    something simple I have overlooked. I have a fairly simply macro that
    moves all the Cells in a range down the sheet by 1 (by cutting and
    pasting). This initially seemed to work, but now i get a "Method
    'Paste' of object '_Worksheet' failed" error when I run it. This is the
    full macro:

    Range("L1:AH500").Select
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollRow = 1
    Application.CutCopyMode = False
    Selection.Cut
    Range("L2").Select
    ActiveSheet.Paste
    Range("I2:I24").Select
    Selection.Copy
    Range("L1:AH1").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
    SkipBlanks:= _
    False, Transpose:=True

    If anyone can help me, please do!


  2. #2
    Carim
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Hi Blork,

    Following should do the job :
    Range("L1:AH500").Select
    Selection.Cut
    ActiveCell.Offset(1, 0).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Select

    Beware of your range selection, if you want to repeat the process ...
    HTH
    Cheers
    Carim


  3. #3
    blork
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Thanks for your help,
    Unfortunately it's still returning with the exact same error, and when
    I go to debug the code, "ActiveSheet.Paste" is still highlighted in
    yellow.


  4. #4
    Carim
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Blork,

    Is your copy paste done within the same worksheet or not ?


  5. #5
    blork
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Originally I was attempting to copy/paste from a seperate Workbook, but
    when that failed (with that error), I tried it from within the same
    sheet, with a modified macro. So, the code that I pasted up there ^^,
    that errors out, is working within the same sheet.


  6. #6
    Carim
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    Blork,

    I guess you mean to copy-paste between different worksheets within the
    same workbook ...
    The workbook is equivalent to an excel File, and the worksheets are
    represented by the different tabs sheet1, sheet2, sheet3 ...
    If you want to operate between sheets, you only have to be specific in
    your range definition, and specify which destination sheet you want ...
    e.g.

    Worksheets("Sheet1").Range("L1:AH500").Select ' for your input
    Worksheets("Sheet2").Range("L2").Paste ' for your destination

    HTH
    Cheers
    Carim


  7. #7
    blork
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    No, I know this....let me explain.
    I was initially attempting to expand a macro I had earlier created to
    carry out another function. This macro is located in one workbook (say,
    "one.xls"). I wanted to be able to copy/paste the values in my 2nd
    workbook ("two.xls") from a button located in "one.xls". When this
    failed with *the* error, I decided to simplify matters, and have the
    function take place in one workbook, "two.xls", copying and pasting
    values in one sheet. This failed too. So now I'm here. Bit complicated,
    I know.

    All I'm asking for help with is the code I posted, which copies in the
    same sheet.

    Thanks.


  8. #8
    Tom Ogilvy
    Guest

    Re: Error in Macro: "Method 'Paste' of object '_Worksheet' failed"

    With Workbooks("Two.xls")
    .Activate
    With .Worksheets("Sheet1")
    .Activate
    .Range("L1:AH500").Select
    Selection.Cut
    .Range("L2").Select
    ActiveSheet.Paste
    .Range("I2:I24").Select
    Selection.Copy
    .Range("L1:AH1").Select
    Selection.PasteSpecial Paste:=xlValues, _
    Operation:=xlNone, _
    SkipBlanks:= _
    False, Transpose:=True
    End with
    End With

    Change Sheet1 to reflect the name of the Sheet in worbook Two.xls

    --
    Regards,
    Tom Ogilvy


    "blork" <[email protected]> wrote in message
    news:[email protected]...
    > No, I know this....let me explain.
    > I was initially attempting to expand a macro I had earlier created to
    > carry out another function. This macro is located in one workbook (say,
    > "one.xls"). I wanted to be able to copy/paste the values in my 2nd
    > workbook ("two.xls") from a button located in "one.xls". When this
    > failed with *the* error, I decided to simplify matters, and have the
    > function take place in one workbook, "two.xls", copying and pasting
    > values in one sheet. This failed too. So now I'm here. Bit complicated,
    > I know.
    >
    > All I'm asking for help with is the code I posted, which copies in the
    > same sheet.
    >
    > Thanks.
    >




+ 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