VBABeginner1
New Member
- Joined
- Dec 6, 2014
- Messages
- 31
Hi I am creating an Employee Database that tracks reports on employees. Basically if an employee has an absence I want to copy the employee name and information and move it to their personal file. I have created this workbook with lots of recorded marco's. So if the employee name is "Barl, Diane" then it copy's the information to Sheet("Barl, Diane") But when I look through all my code, I have the name "Barl, Diane" used 60+ times in different modules and such. I am looking for how to define an array of Employees so that I can put all 100+ employees into an area then be able to condense and simplify the code I have currently the code below works, but whenever I have tried and Array (assuming that what I need) it doesn't work. I have tried so many array videos and threads that I am beyond confused to what the code is supposed to look like in the end. So I am leaving the code that works and hoping that someone can show me how to properly assign multiple employees to an array that I can call upon them throughout the workbook
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets("ShiftReport")
If ws.Range("d1").End(xlDown).Value = AttendanceList.Text = True And ws.Range("g1").End(xlDown).Value = "Barl, Diane" Or ws.Range("h1").End(xlDown).Value = "Barl, Diane" Or ws.Range("i1").End(xlDown).Value = "Barl, Diane" Then
' EmpFileAttend Macro
' Below is the recorded macro that follows, just a small example of what the above code goes into and what I am looking for
Sheets("ShiftReport").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Copy
Sheets("Barl, Diane").Select
Range("G3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("C1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("H3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("D1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("I3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
ActiveWindow.SmallScroll ToRight:=2
Range("L1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("J3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("F1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("K3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets("ShiftReport")
If ws.Range("d1").End(xlDown).Value = AttendanceList.Text = True And ws.Range("g1").End(xlDown).Value = "Barl, Diane" Or ws.Range("h1").End(xlDown).Value = "Barl, Diane" Or ws.Range("i1").End(xlDown).Value = "Barl, Diane" Then
' EmpFileAttend Macro
' Below is the recorded macro that follows, just a small example of what the above code goes into and what I am looking for
Sheets("ShiftReport").Select
Range("A1").Select
Selection.End(xlDown).Select
Selection.Copy
Sheets("Barl, Diane").Select
Range("G3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("C1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("H3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("D1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("I3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
ActiveWindow.SmallScroll ToRight:=2
Range("L1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("J3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("ShiftReport").Select
Range("F1").Select
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Barl, Diane").Select
Range("K3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste