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
Bookmarks