Results 1 to 2 of 2

Thread: Insert Row in Excel Using VBA

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    10

    Resolved Insert Row in Excel Using VBA

    I have read a bunch of posts about inserting a row into excel through VBA, but none helped.

    I tried using this code

    Code:
    Do Until some_condition = true
        Activecell.Offset(1, 0).Select
        If some_condition = true then
            ActiveCell.EntireRow.Select
            Selection.Insert Shift:=xlDown
        End if
    Loop
    but it gives me a Run-Time Error '1004', Insert method of Range class failed. The purpose of the code is to insert a row once it finds the right place/row to insert.

    I saw something about using the following code:

    Code:
    Rows("2:2").Insert Shift:=xlDown
    But that gives me the same error too.

    Any ideas why my code isn't working? I am using VB 6.3
    Last edited by byyu; Dec 12th, 2007 at 01:01 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width