+ Reply to Thread
Results 1 to 3 of 3

Macro - inserting multiple rows

  1. #1
    Registered User
    Join Date
    02-11-2009
    Location
    St Albans, UK
    MS-Off Ver
    Excel 2003
    Posts
    12

    Macro - inserting multiple rows

    Hopefully this will be a straightforward query, but I am a novice when it comes to writing macros.

    Please see the attachment.

    You will see that I have recorded two macros:

    1) To insert a new row for new people.
    2) To insert a row for new animals.

    With regards to 1), I would like to create a macro that copies the contents of the row with the penultimate name in the people section, and for a new row to be inserted beneath the copied cell.

    Similarly, with regards to 2) I would like to create a macro that copies the contents of the row with the penultimate name in the animal section, and for a new row to be inserted beneath the copied cell.

    The issue that I have is that the macros do not copy the penultimate cell in each section, but copy a particular row, say row 11 each time I want to insert a new animal. So if I had inserted numerous new rows for the people section, and subsequently wanted to insert a new row for the animal section, I press “crtl+sht+a” which copies the contents of row 11 and which is not the contents of the penultimate row for the animal section.

    Please can you let me know how I should amend the macros.
    Attached Files Attached Files
    Last edited by douglaswarden; 02-24-2009 at 06:33 AM.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264

    Re: Macro - inserting multiple rows

    Hi

    Please see attached. I have named two ranges on your sheet (Animals and People) - please review b7y going Insert>Name>Define.

    Code for both macros is basically the same:

    Please Login or Register  to view this content.
    Richard
    Attached Files Attached Files
    Last edited by Richard Schollar; 02-23-2009 at 09:46 AM.
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Registered User
    Join Date
    02-11-2009
    Location
    St Albans, UK
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Macro - inserting multiple rows

    Many thanks Richard. Works perfectly.

+ 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