Consulting

Results 1 to 6 of 6

Thread: Solved: Why am I getting an error?

  1. #1
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location

    Solved: Why am I getting an error?

    What is causing an "Object Required" error on the second line of this code? Interestingly, the copy/paste actually occurs as desired, the error notwithstanding.

    [VBA]
    Range("A17").EntireRow.Copy
    Range("A15").EntireRow.Insert(Shift:=xlDown).Paste

    [/VBA]

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Insert is a method that doesn't return an object. Hence the "Object requried" (for the .Paste method) error. Try

    [vba]Range("A15").EntireRow.Insert Shift:=xlDown, CopyOrigin:=True[/vba]

  3. #3
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Quote Originally Posted by mikerickson
    Insert is a method that doesn't return an object. Hence the "Object requried" (for the .Paste method) error. Try

    [vba]Range("A15").EntireRow.Insert Shift:=xlDown, CopyOrigin:=True[/vba]
    Now I'm getting a "Named Argument not found" with respect to the "CopyOrigin". Does the recommended procedure only work on newer versions of Excel? I should have stated at the outset that I'm running Outlook 2000.

  4. #4
    VBAX Regular
    Joined
    Feb 2012
    Location
    Ottawa/Canada
    Posts
    13
    Location

    Responsing to the error you're haviing

    Use this instead.
    [vba]
    Range("A15").Select
    Selection.Insert Shift:=xlDown
    Application.CutCopyMode = False
    [/vba]
    Chuck

  5. #5
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Thanks, chamdan. I was hoping to avoid having to use "Select." I think I have figured out how to make mikerickson's suggestion work.
    Last edited by Opv; 03-31-2012 at 07:11 PM.

  6. #6
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Thanks, by the way, to mikerickson. I appreciate the help.

Posting Permissions

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