+ Reply to Thread
Results 1 to 5 of 5

Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

  1. #1
    Forum Contributor
    Join Date
    01-13-2016
    Location
    Sheffield, England
    MS-Off Ver
    2016
    Posts
    216

    Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

    I have a couple of reports I download on a daily basis.

    One report is the employees name and badge number.
    The other report is employees absenteeism.

    The problem I have is the following:-

    The 'Employee Absences' report does not show the employees full name.
    The 'Employee List' does show the employees full name.

    I need the sheet 'Employee Absences' to pull in the employees full name from the 'Employee List' sheet.

    I then need to create a pivot from this information so I can keep a track of employees absences. (occurrences and total days).
    I have attached a copy of the workbook.
    The sheets within the workbook are exactly as the reports download. When you look at the reports you will understand more why I am struggling.

    I would copy/paste the downloaded reports directly into the 'Employee Absences' and 'Employee List' sheets daily. Hopefully then run some code to give me the above.

    Any help would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

    If I were in your shoes and this were my job, the first thing I'd do is ask for a bespoke report that churns this data out in a sensible and useable format!
    However, the below will potentially do what you need. I've added comments to explain what each part is doing.
    Please Login or Register  to view this content.
    I've added a button to the Employee Absences sheet in the attached. Click it and it will run the code.

    Depending on your machine it'll take a few seconds to run, but it'll still be quicker than doing it manually.

    Some whizz will come along and provide some far more efficient code for you, no doubt.

    Any questions, feel free to ask.

    Hope it helps.

    BSB
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    01-13-2016
    Location
    Sheffield, England
    MS-Off Ver
    2016
    Posts
    216

    Re: Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

    Thanks BadlySpelledBuoy that works a treat.

    just need to get my head around the rest of what i want to pull out of this like trends, occurrences and amount of sick days.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

    Just noticed there's a slight problem with the code above. When it unmerges the cells it causes some duplicatw rows. This is caused by your original data layout rather than the code itself.
    Also the dates are in text format and Excel won't like trying to pivot off of those.

    Adding the below just before the last "End With" will resolve both those issues
    Please Login or Register  to view this content.
    You could add a formula to a 'helper column' that flags the first day of each absence instance to count how many times each person is off.
    Obviously count the records to show the number of days they're off. With a little magictrickery you can calculate average days per absence instance or which specific day of the week they're most often off.

    I've done similar work to this in the past and found it rather interesting to cross reference the absence data with certain events. Very telling how many people were off "sick" on the Monday after their team lost a big game on the Sunday just before...

    Give us a shout if you need more help with it.

    BSB

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Pull Data from sheet 1 to sheet 2 based on content in sheet 2 using vba

    Hello.
    I enclose another approach to the subject in which:

    - Your workbook with the data must be closed.

    - The macro will ask you to select it.

    - And at the end you get the complete data plus a dynamic table with focus on the type of absence.

    Please Login or Register  to view this content.
    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. VBA : Pull Data From Multiple Sheet Into 1 Sheet Based On Criteria
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2022, 11:58 PM
  2. How do I pull and place 'Name' data from Sheet to Sheet based on 'ID'
    By goonshiredgoons in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-13-2015, 03:41 PM
  3. Formula to pull data from one sheet to a new sheet based on date range
    By lisajolley11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-15-2015, 08:38 PM
  4. [SOLVED] VBA Code to Pull Data from a Sheet Based on Date and Add that Data to Another Sheet
    By drsadistic in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-09-2014, 12:53 AM
  5. Replies: 5
    Last Post: 07-23-2013, 01:17 PM
  6. Replies: 4
    Last Post: 09-05-2012, 05:57 PM
  7. based on Cell/Column content ,cut one sheet's values and paste it in other sheet?
    By mindpeace in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2006, 08:33 AM

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