Private Sub CommandButton1_Click()
Dim i As Integer, j As Integer, jj As Integer
ReDim arr(1 To ListBox1.ListCount)
ReDim arr2(1 To ListBox1.ListCount)
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
j = j + 1
arr(j) = ListBox1.List(i)
Else
jj = jj + 1
arr2(jj) = ListBox1.List(i)
End If
Next
ListBox1.Clear
ListBox1.List = arr2
ListBox2.List = arr
End Sub
Private Sub CommandButton2_Click()
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, .Columns.Count).End(xlToLeft).Offset(, 1) = "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, .Columns.Count).End(xlToLeft).Offset(, 1) = "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, .Columns.Count).End(xlToLeft).Offset(, 1) = "Present other"
Next
End With
End Sub
Private Sub CommandButton3_Click()
Dim i As Integer
ReDim arr(1 To ListBox1.ListCount)
ReDim arr2(1 To ListBox1.ListCount)
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
j = j + 1
arr(j) = ListBox1.List(i)
Else
jj = jj + 1
arr2(jj) = ListBox1.List(i)
End If
Next
ListBox1.Clear
ListBox1.List = arr2
ListBox3.List = arr
End Sub
Bookmarks