+ Reply to Thread
Results 1 to 3 of 3

Thread: Insert new rows

  1. #1
    Registered User
    Join Date
    08-21-2011
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    2

    Smile Insert new rows

    hello, I need to insert eg 2 rows, skip one, add 2 rows, skip one, etc.

    For example:

    insert new rows in the A2 and A3, again in A5 and A6, again in A8 and A9, etc.
    It must be the entire row, not just A column.

    I hope one of you good people who can give me a good tip.

    sincerely,
    Hans N.
    Last edited by 2hans; 08-21-2011 at 09:09 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    448

    Re: Insert new rows

    the sample sheet (though trivial) is like this from A1 in sheet 1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    copy sheet 1 to sheet 2 also

    now try this macro test
    Sub test()
    Dim j As Integer
    Worksheets("sheet1").Activate
    j = 2
    Do
    Range(Cells(j, 1), Cells(j + 1, 1)).EntireRow.Insert
    j = j + 3
    If Cells(j, 1) = "" Then Exit Do
     Loop
    End Sub

    Sub undo()
    Worksheets("sheet1").Cells.Clear
    Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
    End Sub

  3. #3
    Registered User
    Join Date
    08-21-2011
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Insert new rows

    Hi venkat1926

    Thx for your great help, this was what I needed. I removed the line "worksheet" I now it works vere nice.

    Sub test()
    Dim j As Integer
    j = 2
    Do
    Range(Cells(j, 1), Cells(j + 1, 1)).EntireRow.Insert
    j = j + 3
    If Cells(j, 1) = "" Then Exit Do
    Loop
    End Sub

    Thx for help.

    Kinds regards
    Hans N

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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.2.0