+ Reply to Thread
Results 1 to 4 of 4

Runtime error 1004

  1. #1
    Zippy
    Guest

    Runtime error 1004

    Can anyone help me as to why I get a run time error 1004 - Insert method of
    Range Class failed
    when this bit of code reaches the "Selection" line?

    Sub compare()

    Row = 1
    Do
    If (Cells(Row, 1) <> Cells(Row, 4)) Then
    Cells(Row, 4).Select
    Selection.Insert shift:=x1down
    Else
    Row = Row + 1
    End If
    Loop Until Row = 20

    End Sub



  2. #2
    Registered User
    Join Date
    02-26-2006
    Posts
    3
    hi

    change shift:=x1Down to shift:=xlDown

    regards yngve

  3. #3
    Joel Berry
    Guest

    RE: Runtime error 1004

    Looks like it should be "xlDown" instead of "x1Down" -- use an "l" instead of
    a "1"

    "Zippy" wrote:

    > Can anyone help me as to why I get a run time error 1004 - Insert method of
    > Range Class failed
    > when this bit of code reaches the "Selection" line?
    >
    > Sub compare()
    >
    > Row = 1
    > Do
    > If (Cells(Row, 1) <> Cells(Row, 4)) Then
    > Cells(Row, 4).Select
    > Selection.Insert shift:=x1down
    > Else
    > Row = Row + 1
    > End If
    > Loop Until Row = 20
    >
    > End Sub
    >
    >
    >


  4. #4
    Zippy
    Guest

    Re: Runtime error 1004

    Thanks guys!! I've looked at this for so long and didn't spot that!!

    Zippy

    "Joel Berry" <[email protected]> wrote in message
    news:[email protected]...
    > Looks like it should be "xlDown" instead of "x1Down" -- use an "l" instead

    of
    > a "1"
    >
    > "Zippy" wrote:
    >
    > > Can anyone help me as to why I get a run time error 1004 - Insert method

    of
    > > Range Class failed
    > > when this bit of code reaches the "Selection" line?
    > >
    > > Sub compare()
    > >
    > > Row = 1
    > > Do
    > > If (Cells(Row, 1) <> Cells(Row, 4)) Then
    > > Cells(Row, 4).Select
    > > Selection.Insert shift:=x1down
    > > Else
    > > Row = Row + 1
    > > End If
    > > Loop Until Row = 20
    > >
    > > End Sub
    > >
    > >
    > >




+ 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