+ Reply to Thread
Results 1 to 3 of 3

Need help with a macro to add & remove rows in specific locations

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Vermont, Dakota
    MS-Off Ver
    Excel 2007
    Posts
    22

    Question Need help with a macro to add & remove rows in specific locations

    Hello -

    I've only had tremendous results from this community and have learned a lot so I return with my newest problem. I'm working on creating a sheet to manage personnel and realized that my life could be made much easier using vba, the trouble is I'm having trouble coming up with it. I've attached what I think is a good example of what I'm looking for that I hope some of you can help me with.

    addpersrempersexample.xlsx

    The task has to do with adding two rows in changing (though following a consistent pattern) locations while also allowing for the removal of the row pair through the click of buttons. It will be much clearer in the example.

    Currently I use a primitive macro too add people and I am forced to manually remove them as I couldn't come up with a suitable removal method:

    Please Login or Register  to view this content.
    In the code offsval is initially equal to 5, the distance between the rows in the first move
    when I remove people I have to be careful to ensure the offsval is changed to be correct

    another minor problem with this code I haven't devoted too much thought to is that the added rows are placed second rather than at the bottom - i understand why this is, but haven't thought of an easy solution given my implementation.


    any direction or help is much appreciated , especially in regards to easily removing people !

    steve

    **** sorry about typo in B8 on example just caught it
    Last edited by thesteve; 01-16-2015 at 03:49 PM. Reason: added apology

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Need help with a macro to add & remove rows in specific locations

    Here's another step for you.
    You can find the range of the button clicked, you would then use that range in your code.
    Please Login or Register  to view this content.
    The above code shows how to get the range of the button clicked.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Need help with a macro to add & remove rows in specific locations

    hi thesteve, option, please check attachment, try to add/remove rows using buttons
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 22
    Last Post: 08-15-2014, 03:06 PM
  2. excel macro to remove specific columns and rows + remove duplicate
    By garrywelson in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-17-2013, 12:03 PM
  3. Remove rows based on specific condition
    By shinichi_nguyen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2012, 02:30 PM
  4. vba macro to remove rows if different from specific cell
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-06-2011, 01:28 PM
  5. Advanced function to remove specific rows
    By nemadrias in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-10-2006, 03:04 PM

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.6.0 RC 1