03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
I have developed an employee attendance form that has a dropdown list where the user selects the employee they want to see. The users are interested in seeing the last 24 payroll periods, most recent first. When they complete this, based on the 24 payroll periods, the attendance violations show up in appropriate 1-31 columns. I am in the process of setting up a UserForm instead of using formulas in a spreadsheet.
Is there a way to duplicate this excel formula: =MAX(IF(Table1[Employee]=EmployeeName,Table1[SDay]))
I have started writing the code but need help with:
1. CBO_EMPLOYEE_CHANGE event - keep getting an error 13 type mismatch on my code and need some help.
2. How to I populate the 24 date textboxes - Order: Newest to Oldest
Here is snippet of my Table1 where the data is stored:
Here is a snippet of my UserForm layout:
Code I have so far:
Is there a way to duplicate this excel formula: =MAX(IF(Table1[Employee]=EmployeeName,Table1[SDay]))
I have started writing the code but need help with:
1. CBO_EMPLOYEE_CHANGE event - keep getting an error 13 type mismatch on my code and need some help.
2. How to I populate the 24 date textboxes - Order: Newest to Oldest
Here is snippet of my Table1 where the data is stored:
Here is a snippet of my UserForm layout:
Code I have so far:
VBA Code:
Private Sub UserForm_Initialize()
Dim i As Long
Dim va, x
Dim d As Object
Set d = CreateObject("scripting.dictionary")
va = Sheets("Absentee").Range("C3:C100000")
For Each x In va
d(x) = Empty
Next
CBO_EMPLOYEE.List = d.keys
End Sub
Private Sub CBO_EMPLOYEE_CHANGE()
If Me.CBO_EMPLOYEE.ListIndex > -1 Then
Me.TXT_DATE1.value = WorksheetFunction.VLookup(CLng(Me.CBO_EMPLOYEE.value), _
Sheets("Absentee").Range("Table1"), 11, False)
End If
End Sub