+ Reply to Thread
Results 1 to 3 of 3

Add row at specific location using vba

  1. #1
    Registered User
    Join Date
    02-05-2011
    Location
    Ottawa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Add row at specific location using vba

    Hi All,

    I have a spreadsheet (testing - attached) that has several sections with buttons that add and remove rows for that section. In my attached spreadsheet, the add button is only functional for Objectives. My code adds a new row after whatever cell is selected. I need it to go to a cell I've named "OBJ", select the row above it, copy and paste so the cell "OBJ" gets moved down to the next row (to be used if another row is added). The code I have so far is below, it copies the selected row and adds a new row below it, not quite what I am looking for:
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.

    Thanks.
    Attached Files Attached Files
    Last edited by Leith Ross; 02-05-2011 at 03:47 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Add row at specific location using vba

    Hello hrbreton,

    Welcome to the Forum!

    Both "add" buttons have the new macro attached to them. This uses the position of the button along with the bordering empty rows to determine the last row. There must be at least 3 rows present before the row will be copied. The two headers rows are excluded. The attached workbook has the macro added.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-05-2011
    Location
    Ottawa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Add row at specific location using vba

    Thanks for your reply. I have written some vba which does the trick. I hope it helps someone else:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-06-2011 at 03:16 PM. Reason: Added Code Tags

+ 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