I am working on a workers comp report. I have a list of all the employee names, comp code, dept code on Sheet 2 named Dept_rng. To clarify, the list is named "Dept_rng" which resides on Sheet 2.
On Sheet 1, I have the Employee Names with Payroll info. I also have blank rows that will return an error if I apply the formulas needed to calculate the worker comp for a specific employee designated by a specific row Cells(i , 1).
I need to search the Named Range on Sheet 2 "Dept_rng" for the name on page one, one cell(Cells(i , 1) at a time. If find the name on Sheet one in Dept_rng Sheet2 is not found than Next i. If it is there then add formula to rows on Sheet 1.
Here is the best I have come up with which does not work.
Suggestions Please
Thanks,
Mozzz
On Sheet 1, I have the Employee Names with Payroll info. I also have blank rows that will return an error if I apply the formulas needed to calculate the worker comp for a specific employee designated by a specific row Cells(i , 1).
I need to search the Named Range on Sheet 2 "Dept_rng" for the name on page one, one cell(Cells(i , 1) at a time. If find the name on Sheet one in Dept_rng Sheet2 is not found than Next i. If it is there then add formula to rows on Sheet 1.
Here is the best I have come up with which does not work.
Code:
Sub PostFormulas()
' Search NameRange for EmployeeName if Error Go to next line
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
On Error Resume Next
Names.Add Name:="EmpName", RefersTo:=Sheets(2).Range("A2:A70")
For i = 12 To FinalRow
MyVariable = Cells(i, 1)
Sheets(2).Range("EmpName").Find(What:=MyVariable, LookAt:=xlWhole, _
LookIn:=xlValues) = x
Sheets(2).Range("L2:O2").Copy Destination:=Sheets(1).Cells(i, 10)
Next i
End Sub
Suggestions Please
Thanks,
Mozzz