+ Reply to Thread
Results 1 to 29 of 29

Copying data from a certain sheet to another sheet for attendance in VB

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Copying data from a certain sheet to another sheet for attendance in VB

    Hi guys!

    I really need your help regarding extracting data from a certain sheet to another sheet using VB. There is an excel file that contains the name, date, timetable or schedule, the log-in, the log-out and the ATT_Time of the employees. I attach the excel file here with filename sampleattendance. Mainworksheet is the name of the sheet which contains the data.

    What I need to do is the name, date, timetable, log-in and log-out and the ATT_Time of every employee should be extracted on different worksheets which means every employee has a worksheet which contains all the data from the main worksheet. The format of the new worksheet for every employee is on sheet2. The data should be extracted on columns N13, 0O13, P13, Q13,R13,S13.

    After it has been extracted, the log.in and log out per date should be extracted also on the table found on every employee's sheet.

    Below are the bases on where to put the log-in and log-out.

    For Morning:

    7-3; 9-6 ; 6-2; 4:30am-12:30pm ; 8:30am-5:30pm; 5am-1pm

    For Afternoon:

    12:30pm-8:30pm ; 4pm-12am; 2-10

    For Evening:

    8:30pm-4:30am; 10-6; 9pm-5am


    I really hope you can help me on this. If you have confusions regarding my problem, just ask me. Thank you so much. sampleattendance.xlsx
    Last edited by blueswan; 05-31-2012 at 08:09 AM.

  2. #2
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Extracting data from a certain sheet to another sheet for attendance in VB

    i really need your help on this one guys..

  3. #3
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Extracting data from a certain sheet to another sheet for attendance in VB

    please help me on this

  4. #4
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Extracting data from a certain sheet to another sheet for attendance in VB

    please please help me. i need this for my job

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    hi blueswan, please check attachment, press Run

    Sheet Template is used for creating each employee sheet
    Attached Files Attached Files
    Last edited by watersev; 05-31-2012 at 08:54 AM.

  6. #6
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    thanks for the help
    Last edited by blueswan; 05-31-2012 at 11:09 AM.

  7. #7
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Extracting data from a certain sheet to another sheet for attendance in VB

    Thank you so much watersev! Is the code applicable to more dates for example if the date is from May 1-15 or from May 16-30?

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    as per your sample file template to be filled in ends on row 30 (19 rows of data per employee) so that is the limitation for now

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    if you want template to allow more data rows:
    1. Amend template sheet
    2. Amend code line (2 instances):
    Please Login or Register  to view this content.
    where i30 - last data row for now. Change it to new reference, ex. i100

  10. #10
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    i tried the code on this file but i get an error that subscription is out of range.. sheetsample2.xlsx

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    have you noticed that your sample file data structure differs from the real one - it has empty rows between each employee. What is the point to make it different from the sample file you post?

    Please check attachment
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Thank you so much. It works. Can the data on the column ATT_time be extracted also on the template? It will be placed on the column Time Worked. Attach is the excel file containing the new template.. sheetsample2(1).xlsm

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    please check attachment
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Sorry for the late reply.. I will try now the new file you attached.. I will give feedback later.. Thank you so much..

  15. #15
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Hi watersev! It works. Can I request to add something in the code. If there's no log-out or log-in on the mainworksheet for every employee, is it possible to display no log-out or log-in on the table also and color it red just to identify?

  16. #16
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Hi watersev! Would it be possible to convert the log-in and log-out extracted from the mainworksheet to a 12 hour clock? For example if its 21:05 at the main worksheet, it will become 9:05 pm on the table? Would that be alright?

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    1. If log-in time is present and log-out is absent, log-out becomes highlighted (row 117, Ella) and vice versa. Conditional format is used.
    2. The format displayed on the sheet is AM/PM though values stay in 24H format, is that acceptable?
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Thanks waterserv. It works. But for Time Worked column, there's no need for the 12 hr format.. The output should just be the same as what is found on the mainworksheet. I have also question, what if the employee's schedule is openshift, meaning there's no specific schedule for him. Can their log-in and log-out be plotted also?

    Attach is the sample file for employees with openshift.. The macro for this can be different. openshift.xlsx

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Re Time Worked column: change number format on Template sheet for this column and run code again

  20. #20
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    ok.. thanks.. i got it.. how about for the openshift schedule? would that be possible?

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    i do not see any explanation in the file provided or result sheet that should be obtained as a result

  22. #22
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Here's what should be outcome.. If the employee's log in is from 4:00 am to 12 pm then it should go to the morning log in.. if the log in is from 12:01 pm to 6 pm, it will go to the afternoon log in.. if the log-in is from 6 pm to 3:59 am it will go to the evening log-in.. For the log-out, if the employee log out 4:00 am to 12 pm, it will go to morning log-out.. If the employee log-out from 12:01 pm to 6 pm, it will go to afternoon log-out and if the employee log-out from 6:01 pm to 3:59 am it will go to the evening log-out.. then the att_time column on the mainworksheet will be plotted also on the Time Worked column on the template.. no need to put no clock in or no clock out if clock in is not found or clock out is not found. hope you can help..

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    I hope after posting solution to your last question you would not ask me what whould be the code if shifts are mixed . If you are going to do that, tell it now

  24. #24
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Hmm.. I',m so sorry didn't get what you mean.. but for this problem, you may have a separate macro for this.. because the macro for this one is exclusive only for those who have openshifts..

  25. #25
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Looks like this question is being asked by 2 different people, here's the other thread:
    http://www.excelforum.com/excel-prog...html?p=2808814
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    please check attachment, press Run on "idig open 16-30" sheet
    Attached Files Attached Files

  27. #27
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    Thank you so much watersev. I will try the file you attach later.. I will give feedback after trying it..

  28. #28
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    thank you so much watersev. i already tried the codes. it works perfectly.. thank you so much.. i will now close this thread..

  29. #29
    Registered User
    Join Date
    05-21-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Copying data from a certain sheet to another sheet for attendance in VB

    hi watersev.. i hope you could help me on this new problem i posted.. here's the link of the thread http://www.excelforum.com/excel-prog...ch-in-vba.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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