+ Reply to Thread
Results 1 to 15 of 15

Insert New Employee

  1. #1
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Insert New Employee

    Gurus,

    I have scoured the internet for a solution.

    Ultimately I am trying to create a macro of which the user enters a new employees first and last name. The macro places that in column "B" and in row by alphabetic order.

    User enters: Cosmo Kramer

    List (column B)
    George Constanza
    Jerry Steinfeld

    Result

    George Constanza
    Cosmo Kramer
    Jerry Steinfeld

    I am using bits and pieces of code I found but I cannot figure out how to define LastnameLP and FirstnameLP variables.

    Please help, or let me know if there is an easier way. I need to keep the first and last name in the same cell.

    Tia,
    Tim

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    I don't think that there is a direct way of doing what you want if both first and last names are in the same cell where the first name comes before the last name and you want to sort by last name. You would have to insert a blank column and place just the last name in that column and then use that column to sort. Once the sorting is done, that new column can be deleted. Another complication is if there are middle names or initials.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps1,

    So, you think if I used some helper cells to split the first and last name into separate cells I could simply run with what I have so far? Just define FirstnameLP as the value of the first name helper cell and the LastnameLP as the last name helper cell?

    If so, that would look like firstnameLP = range(helpercell).value?

    I am aware of middle names and initials however for the purpose of what I am trying to accomplish, the user has to use only first and last names as a rule.

    Tim

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    If you could post a copy of your file (de-sensitize if necessary) it would be easier to help. Include a detailed explanation of what you want to do using a few examples from your data and referring to specific cells, rows and columns.

  5. #5
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps1,

    See the attached spreadsheet.

    We could use columns AH and AI for Last and First Names.

    Tim
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    OK. I had a look at your file. Can you now explain step-by-step exactly what you want to do using a few examples. Also could you upload a version of your file that includes the "Save", "Insert Row" and "Employee_Names" macros. We have to make sure that any new macro doesn't interfere with the existing ones.

  7. #7
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps1,

    The user will run macro,

    the user will enter the first and last name of the new employee into the input box

    the macro will look in column "b" to see where the last name of the new employee will fit alphabetically.

    the macro will insert a new row (copying all the formulas) and enter the employees name in the column "b" of the new row.

    just that easy.... so I thought!

    Thanks,
    Tim
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    Have a look at the attached file. You will notice that there are 2 empty rows (rows 19 and 20). Don't delete either of these 2 rows. They are necessary to adjust the formulas correctly. Click the "Add Employee" button at the top. The macro will do the following:
    -Prompt you to enter an employee name ... First Name - Last Name
    -Prompt you to enter an Employee Number
    -Enter that data into the appropriate columns (including AH and AI)
    -Copy and adjust the necessary formulas
    -Place the names in alphabetical order
    -Copy the names to the "Employee" sheet
    -Create a new sheet for the newly added employee.
    Please let me know how this works out for you
    Attached Files Attached Files
    Last edited by Mumps1; 02-15-2018 at 02:25 PM.

  9. #9
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps!,

    Can you upload the file? I tried to paste your code into my workbook and it didn't work. Not sure if you filled names in the AH and AI columns or not.

    Thanks.
    Tim

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    The file has been added to Post #8.

  11. #11
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    mumps!,

    WOW! This is awesome!

    Any idea why I am getting a run-time error 424 Object required on line

    Please Login or Register  to view this content.
    Tim

  12. #12
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps!

    Nevermind. I found the error... foundrow should be findrow...

    Works GREAT!!

    Thank you very much!!!

    Tim

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    You are very welcome.

  14. #14
    Forum Contributor
    Join Date
    06-21-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    186

    Re: Insert New Employee

    Mumps!,

    I am trying to learn as I go...
    Can you provide a quick explanation of what the (- 2) and (-3) are doing in this code?

    Please Login or Register  to view this content.
    Also, If I enter Abe Abraham as a new employee, his row is inserted after Greg Clem.

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Insert New Employee

    Try the attached file. I have fixed the alphabetizing problem. "Findrow.row" is a variable that represents the row number of the cell containing "Total Hours". The (- 2) and (-3) subtract 2 and 3 respectively from the row number containing "Total Hours". For example, if Findrow.row=20 then subtracting 3 will change its value to 17 which is the value I need because it refers to the row number of the last name in column B. I hope this makes sense.
    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. userfrom consist of 3 list box to insert attendance for employee
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-20-2017, 05:08 AM
  2. convert multiple employee records to one record per employee
    By jmccullough in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-27-2016, 10:39 AM
  3. Insert Picture In Cell By Matching Employee ID
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2015, 03:23 AM
  4. Generate output employee data from input employee sheet
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2015, 05:28 PM
  5. Excel Automatically Insert Employee Number
    By ryanb4614 in forum Excel General
    Replies: 3
    Last Post: 09-06-2013, 09:15 AM
  6. insert missing date per employee
    By uidards in forum Excel General
    Replies: 2
    Last Post: 05-24-2013, 03:27 AM
  7. Insert Pay Rate Based On Employee Selected
    By Spencer in forum Excel General
    Replies: 5
    Last Post: 02-06-2009, 03:58 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