VBABeginner1
New Member
- Joined
- Dec 6, 2014
- Messages
- 31
Hello,
I have been pulling my hair out trying to troubleshoot this code. The code was originally created with recorded marco's. I had it working when it referenced a single employee and tracked the output from a userform into their employee file, but since I have to write the code for multiple employees I have attempted to introduce arrays to make it easier to code later down the road as employee turnover happens.
I am receiveing a "Run Time Error 13 - Type Mismatch" on the line below that is in RED.
Please help as I have spent too much time on this code and can't move any farther.
I have been pulling my hair out trying to troubleshoot this code. The code was originally created with recorded marco's. I had it working when it referenced a single employee and tracked the output from a userform into their employee file, but since I have to write the code for multiple employees I have attempted to introduce arrays to make it easier to code later down the road as employee turnover happens.
I am receiveing a "Run Time Error 13 - Type Mismatch" on the line below that is in RED.
Please help as I have spent too much time on this code and can't move any farther.
Rich (BB code):
Dim EmpDrop1, EmpDrop2, EmpDrop3 As String
Dim AttendCell As String
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets("ShiftReport")
EmpDrop1 = ws.Range("g1").End(xlDown).Value
EmpDrop2 = ws.Range("h1").End(xlDown).Value
EmpDrop3 = ws.Range("i1").End(xlDown).Value
AttendCell = ws.Range("d1").End(xlDown).Value
Dim AttendArray As Variant, y As Long
Dim EmpArray As Variant, X As Long
EmpArray = Application.Transpose(Range("EmployeeList"))
For X = LBound(EmpArray) To UBound(EmpArray) '<-- This loops from the lower boundary to the upper boundary
Next
AttendArray = Application.Transpose(Range("AttendanceType"))
For y = LBound(AttendArray) To UBound(AttendArray)
Next
If AttendCell = AttendArray And EmpDrop1 = EmpArray Then
'EmpFileAttend Macro
Sheets("ShiftReport").Range("A1").End(xlDown).Copy
Sheets(EmpArray(X)).Range("G3").End(xlDown).Range("A1").Paste
Sheets("ShiftReport").Range("C1").End(xlDown).Copy
Sheets(EmpArray(X)).Range("H3").End(xlDown).Offset(1, 0).Range("A1").Paste
Sheets("ShiftReport").Range("D1").End(xlDown).Copy
Sheets(EmpArray(X)).Range("I3").End(xlDown).Offset(1, 0).Range("A1").Paste
Sheets("ShiftReport").Range("L1").End(xlDown).Copy
Sheets(EmpArray(X)).Range("J3").End(xlDown).Offset(1, 0).Range("A1").Paste
Sheets("ShiftReport").Range("F1").End(xlDown).Copy
Sheets(EmpArray(X)).Range("K3").End(xlDown).Offset(1, 0).Range("A1").Paste
'' EmpFileAttend Macro
ActiveCell.Offset(0, -4).Range("A1:E1").Select
ActiveCell.Activate
Application.CutCopyMode = False
With Selection.Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent2
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
Call boxthem
End With
ElseIf AttendCell = AttendArray And EmpDrop1 = EmpArray Or EmpDrop2 = EmpArray Or EmpDrop3 = EmpArray Then
Range("A1").End(xlDown).Range("A1:F1").Copy
Sheets(EmpArray).Range("A1").End(xlDown).Offset(1, 0).Range("A1").Paste
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
Call boxthem
End With
End If
Last edited by a moderator: