I am using a macro to cal culate arrears and employees deta getting from other closed work book shee to a array "Employee_Deta". For Arrears format,
"Error - Increment & Arrears Format.xlsm" file and for deta sheet, "Employees Deta.xlsx" file are in same folder. Selected deta are in array but below code part not working correcly. I have attached Arrears format file and Deta sheet file
Code: Select all
matchDate1 = empNo & "-" & Format(startDate, "yyyy-mm")
matchDate2 = empNo & "-" & Format(endDate, "yyyy-mm")
' Initialize matchRow variables
matchRow1 = 0
matchRow2 = 0
' Iterate through the Employee_Deta array to find matching rows
For i = 2 To UBound(Employee_Deta, 2)
If Employee_Deta(2, i) & "-" & Format(Employee_Deta(1, i), "yyyy-mm") = matchDate1 Then
matchRow1 = i
End If
If Employee_Deta(2, i) & "-" & Format(Employee_Deta(1, i), "yyyy-mm") = matchDate2 Then
matchRow2 = i
End If
If matchRow1 > 0 And matchRow2 > 0 Then Exit For
Next i
' Transfer In or Active Employee Update
If matchRow1 > 0 Then
sal_01 = Employee_Deta(5, matchRow1)
End If
' Check if sal_01 is an error or matchRow1 is 0
If IsError(sal_01) Or matchRow1 = 0 Then
With ws.Range("F1")
.Value = "Transfer In or Out of Range"
.Interior.Color = RGB(250, 100, 0)
End With
Else
With ws.Range("F1")
.Value = "Active Employee"
.Interior.ThemeColor = xlThemeColorAccent3
End With
End If
Br,
Priyantha.