+ Reply to Thread
Results 1 to 8 of 8

Macro for adding rows after previous row?

  1. #1
    Registered User
    Join Date
    01-16-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    17

    Question Macro for adding rows after previous row?

    I have this simple macro which copy row 17 and paste it to row 18:

    Code:
    Please Login or Register  to view this content.
    How can it be written so if I run it again it will copy from row 18 and paste to row 19?

    Also, if I close and open the workbook again, will it start over from row 17?

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro for adding rows after previous row?

    Maybe like this. Note that the row copied is the top row of the current selection.
    Please Login or Register  to view this content.
    Last edited by shg; 01-17-2010 at 12:40 PM. Reason: typo
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro for adding rows after previous row?

    Using a convenient cell say "A1"

    in ThisWorkbook
    Please Login or Register  to view this content.
    Insert in a standard module
    Please Login or Register  to view this content.
    Do you want to clear rows on opening workbook?
    Last edited by Marcol; 01-17-2010 at 12:43 PM. Reason: Typo in code

  4. #4
    Registered User
    Join Date
    01-16-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro for adding rows after previous row?

    Quote Originally Posted by shg View Post
    Maybe like this. Note that the row copied is the top row of the current selection.
    Please Login or Register  to view this content.
    That works great! Now I just need to figure out if it can "detect" weather or not the row already has content ( to avoid overwriting other content)

    thnx

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro for adding rows after previous row?

    Whether the row below has anything in it? What if it does?

  6. #6
    Registered User
    Join Date
    01-16-2010
    Location
    Denmark
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro for adding rows after previous row?

    well, if the row below has anything in it it should not paste! rather open a msgbox with some text.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro for adding rows after previous row?

    Please Login or Register  to view this content.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Macro for adding rows after previous row?

    Thought there had to be more than the original post suggested.
    Otherwise why not just use Ctrl+D.

+ 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