Consulting

Results 1 to 3 of 3

Thread: VBA code for attendance template - In time & Out Time

  1. #1

    VBA code for attendance template - In time & Out Time

    Hi, I am trying create attendance template using VBA. I managed to create one. But if I have a IN & OUT time on different dates (Example - In on 9/11/2017 8 PM and OUT on 10/11/2017 8 AM) i am not able to get it proper. Here I want a code to work on both (IN & OUT on the same day and IN & OUT on different dates). Please see the attendance data below:

    Date & Time Transaction Type
    03/01/2016 8:38 I
    03/01/2016 18:36 O
    04/01/2016 8:12 I
    04/01/2016 17:23 O
    06/01/2016 8:14 I
    06/01/2016 19:17 O
    07/01/2016 20:00 I
    08/01/2016 10:02 O
    10/01/2016 8:22 I
    11/01/2016 19:51 O
    13/01/2016 8:22 I
    13/01/2016 19:51 O

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    You didn't say what you wanted to end result to look like. Attaching a sample workbook with a Before and After and enough data to show the issue really helps

    This assume that the data is 'nice' and take the input sheet with data like your post, and puts it on another sheet

    You're have to massage it to fit your template

    Option Explicit
    Sub test()
        Dim i As Long, o As Long
        
        o = 2
        With Worksheets("Sheet1")
            For i = 2 To .Cells(1, 1).CurrentRegion.Rows.Count Step 2
                Worksheets("Sheet2").Cells(o, 1).Value = .Cells(i, 1).Value
                Worksheets("Sheet2").Cells(o, 2).Value = .Cells(i + 1, 1).Value
                o = o + 1
            Next I
        End With
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3

    VBA code for attendance template - In time & Out Time

    Thank for your reply. I am attaching the template and the code which i used in that sheet.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •