+ Reply to Thread
Results 1 to 2 of 2

Writing a macro

  1. #1
    Registered User
    Join Date
    10-26-2005
    Location
    Sydney
    MS-Off Ver
    2007
    Posts
    2

    Smile Writing a macro

    I need to write a macro that will allow me to add any number of rows (as desired) BETWEEN each of the existing values in column A. Now when this is done, it must at the same time populate these new rows with with cell values above the inserted rows.

    So if A1 = Apples... and I add 5 rows,only the cells inserted in col A below A1 should take the value "Apples" until the next value Pears. Then the next 5 cells below Pears should have "Pears".

    Hope this is explained clearly.

    Thanx
    Roxio

  2. #2
    Don Guillett
    Guest

    Re: Writing a macro

    One way

    Sub addrowsandfill()
    For i = Cells(Rows.Count, "a").End(xlUp).Row To 12 Step -1
    x = Cells(i, 1)
    If Cells(i, 1) <> Cells(i - 1, 1) Then
    Cells(i, 1).Resize(4).EntireRow.Insert
    Cells(i, 1).Resize(5).Value = x
    End If
    Next
    End Sub


    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Roxio" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I need to write a macro that will allow me to add any number of rows (as
    > desired) BETWEEN each of the existing values in column A. Now when this
    > is done, it must at the same time populate these new rows with with cell
    > values above the inserted rows.
    >
    > So if A1 = Apples... and I add 5 rows,only the cells inserted in col A
    > below A1 should take the value "Apples" until the next value Pears.
    > Then the next 5 cells below Pears should have "Pears".
    >
    > Hope this is explained clearly.
    >
    > Thanx
    > Roxio
    >
    >
    > --
    > Roxio
    > ------------------------------------------------------------------------
    > Roxio's Profile:

    http://www.excelforum.com/member.php...o&userid=28366
    > View this thread: http://www.excelforum.com/showthread...hreadid=479478
    >




+ 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