+ Reply to Thread
Results 1 to 4 of 4

VBA to add new rows to worksheet table

  1. #1
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Question VBA to add new rows to worksheet table

    Hi everyone,
    I'm not an expert in VBA and I need help with a payroll workbook that I'm working on.
    With the help of "Dinish Kumar" I've been able to create a user form to add new employees to my database on worksheet "Employees".
    So whenever there is a new employee I would go to the form and fill in the cells and run the macro to add the employee to the Main Table.

    (For simplicity purposes I will refer to "Main Table" to the one under the Employees Worksheet and "Second Table" to the one in Sheet1).

    So, the Second Table should contain the same employee names as the Main Table (mostly, unless the employee is terminated or quits). The rest of the data (besides the Last Name and First Name columns) is independent in both worksheets.

    My goal is to have the Second Table automatically update with ONLY the employee Last Name and First Name if I add a new record to my Main Table. The VBA code would add the new row (new employee) in the Second Table (following the alphabetical order of the table). Hopefully this could happen simultaneously as soon as I press the "Add Record" button.

    Additional to that, I would like to delete an employee from the Second Table if I add a Term Date in the Main Table (I could probably add another button for that).

    I have attached what I have so far in my workbook.

    Any help is greatly appreciated.

    Thank you
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: VBA to add new rows to worksheet table

    Hi sandy1977,
    This example does what you asked for. (example with real tables and a real user form)
    If you enter a new employee, employee will also be added to sheet 2.
    If Term date field is not empty and you push the change button Employee will be deleted in sheet 2.
    Employees have an unique number (ID) It is important that the employees have the same ID in sheet 1 en and sheet 2.
    See attached
    Attached Files Attached Files
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Re: VBA to add new rows to worksheet table

    Thanks so much dotchiejack,
    So far it looks really good, I need to play with it more and I'll let you know if something comes up. Thanks again

  4. #4
    Registered User
    Join Date
    08-23-2014
    Location
    Miami, USA
    MS-Off Ver
    365
    Posts
    69

    Re: VBA to add new rows to worksheet table

    Hi dotchiejack,
    I finally used your form and it works perfectly, thank you so much for your help.

    There's a couple of things I would love to improve:

    1.Is it possible to add the new employee following the alphabetical order of the tables?
    2.And is it possible to add the new employee as a new row to the table whenever a new employee is added, instead of just adding them to the last row available?

    Thanks again for all your help.

+ 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. Add/delete table rows on protected worksheet
    By DougieJLockhart in forum Excel General
    Replies: 2
    Last Post: 04-30-2018, 02:29 AM
  2. Pulling Entire Rows of Data from a table or other worksheet
    By CoachSchills in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-02-2018, 03:25 PM
  3. [SOLVED] VBA copy rows in table containing values in list, paste in another worksheet
    By wannabeexcelguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2015, 07:29 PM
  4. [SOLVED] Extracting rows into a self-populating table on another worksheet - please help!
    By mcpoogle in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-16-2013, 08:48 AM
  5. Replies: 14
    Last Post: 04-07-2012, 06:31 PM
  6. Appending rows to existing worksheet/table
    By notaprogrammer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2008, 08:28 PM
  7. [SOLVED] Display specific rows from table on other worksheet
    By Bruno G. in forum Excel General
    Replies: 2
    Last Post: 01-20-2005, 08:06 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