+ Reply to Thread
Results 1 to 17 of 17

userfrom consist of 3 list box to insert attendance for employee

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: userfrom consist of 3 list box to insert attendance for employee

    With modifications, all listboxes are multi select
    you can move between listboxes as match if you want


    Private Sub CommandButton1_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) Then
            ListBox2.AddItem (ListBox1.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox1.List(i) & "|"
            Else
                mystring = mystring & ListBox1.List(i) & "|"
            End If
        End If
    Next
    ListBox1.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox1.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    
    Private Sub CommandButton2_Click()
    If Not IsDate(TextBox1) Then
        MsgBox "No valid date"
        TextBox1 = ""
        TextBox1.SetFocus
        Exit Sub
    Else
        Dim mydate As Double
        mydate = DateValue(TextBox1)
        With Sheets("Attendance")
            mycol = Application.Match(mydate, .Range("A8", "XFD8"), 0)
        End With
    End If
    With Sheets("Attendance")
        For i = 0 To UserForm1.ListBox1.ListCount - 1
            myrow = Application.Match(UserForm1.ListBox1.List(i), .Range("A:A"), 0)
            If Not IsError(myrow) Then .Cells(myrow, mycol) = "Present"
        Next
        For i = 0 To UserForm1.ListBox2.ListCount - 1
            myrow = Application.Match(UserForm1.ListBox2.List(i), .Range("A:A"), 0)
            If Not IsError(myrow) Then .Cells(myrow, mycol) = "Absent"
        Next
        For i = 0 To UserForm1.ListBox3.ListCount - 1
            myrow = Application.Match(UserForm1.ListBox3.List(i), .Range("A:A"), 0)
            If Not IsError(myrow) Then .Cells(myrow, mycol) = "Present other"
        Next
    End With
    Unload Me
    End Sub
    
    Private Sub CommandButton3_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox1.ListCount - 1
        If ListBox1.Selected(i) Then
            ListBox3.AddItem (ListBox1.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox1.List(i) & "|"
            Else
                mystring = mystring & ListBox1.List(i) & "|"
            End If
        End If
    Next
    ListBox1.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox1.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    
    
    Private Sub CommandButton4_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) Then
            ListBox1.AddItem (ListBox2.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox2.List(i) & "|"
            Else
                mystring = mystring & ListBox2.List(i) & "|"
            End If
        End If
    Next
    ListBox2.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox2.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    
    Private Sub CommandButton5_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.Selected(i) Then
            ListBox3.AddItem (ListBox2.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox2.List(i) & "|"
            Else
                mystring = mystring & ListBox2.List(i) & "|"
            End If
        End If
    Next
    ListBox2.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox2.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    
    Private Sub CommandButton6_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox3.ListCount - 1
        If ListBox3.Selected(i) Then
            ListBox1.AddItem (ListBox3.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox3.List(i) & "|"
            Else
                mystring = mystring & ListBox3.List(i) & "|"
            End If
        End If
    Next
    ListBox3.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox3.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    
    Private Sub CommandButton7_Click()
    Dim i As Integer, mystring As String
    For i = 0 To ListBox3.ListCount - 1
        If ListBox3.Selected(i) Then
            ListBox2.AddItem (ListBox3.List(i))
        Else
            If mystring = "" Then
                mystring = ListBox3.List(i) & "|"
            Else
                mystring = mystring & ListBox3.List(i) & "|"
            End If
        End If
    Next
    ListBox3.Clear
    If InStr(1, mystring, "|") > 0 Then
        ListBox3.List = Split(Left(mystring, Len(mystring) - 1), "|")
    End If
    End Sub
    Kind regards
    Leo
    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. Employee Attendance Tracker Help :)
    By Block118 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-18-2017, 06:48 AM
  2. Employee Attendance help please
    By fredek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2016, 12:06 PM
  3. [SOLVED] Employee Attendance Template
    By mcanny in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-18-2016, 01:07 PM
  4. Track Employee Attendance
    By maabbas in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-17-2015, 08:17 AM
  5. Need Help - AutoCalculate Attendance Points for employee attendance records
    By switzd0d in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-17-2015, 03:00 PM
  6. Employee Attendance Record
    By PurpleMe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-23-2013, 02:15 AM
  7. employee attendance
    By ruth in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-08-2005, 12:06 PM

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