+ Reply to Thread
Results 1 to 5 of 5

Run time error - Method range of object failed message when trying to cut entire row

Hybrid View

  1. #1
    Registered User
    Join Date
    12-31-2010
    Location
    Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    13

    Run time error - Method range of object failed message when trying to cut entire row

    I am new to excel macros and VBA. Here's my code. I'm trying to cut a row and paste it after the last cell in the previous row. It's getting hung up on the fourth line of the code.


     If PrevYear = CurrYear Then
               Selection.EntireRow.Cut
               Selection.Offset(-1, 0).Select
               Range(ActiveCell).End(x1LastColumn).Select
               Range(ActiveCell, ActiveCell.Offset(0, 1)).Paste
            End If
    Any help would be appreciated.
    Last edited by almilw; 01-04-2011 at 11:56 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,260

    Re: Run time error - Method range of object failed message when trying to cut entire

    Hi almilw,

    before you look at
    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Edit your post by clicking on the green "Edit" button below your message. Then click on "Go Advanced", Select the code in the message and click on the "#" icon just above the message. This will put code tages around your code and make you a better poster on the site.

    After doing the above look at the possible things that can go after End.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    12-31-2010
    Location
    Wisconsin
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Run time error - Method range of object failed message when trying to cut entire

    I'm not sure what to put after End. I don't know VBA so I'm just stabbing in the dark at what to do.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,260

    Re: Run time error - Method range of object failed message when trying to cut entire

    Hi almilw,

    There are only 4 things that can go in the () after .End, they would be: xlUp, xlDown, xlToRight or xlToLeft.

    Based on your pseudo code above I believe you wanted to do a.
    Range(ActiveCell).End(xlToRight).Select
    I hope that helps.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,976

    Re: Run time error - Method range of object failed message when trying to cut entire

    You cannot paste an entire row to anywhere other than column A, since it won't fit.
    Everyone who confuses correlation and causation ends up dead.

+ 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