I have a workbook for payroll data from which I need to create a ready template payslip. The identifier when creating a new worksheet will be the name of the employee. The template is created but I have trouble reflecting the data in loop. it's not returning the data I need.
I'm using a simple VBA as I've been trying to create the payroll slip manually:
Set wsPay = .Sheets("Payroll")
Set wsTEMP = .Sheets("Template")
Range("F6").Select
ActiveCell.FormulaR1C1 = wsPay.Range("AI" & Rows.Count).End(xlDown).row + 1
Range("J6").Select
ActiveCell.FormulaR1C1 = wsPay.Range("E" & Rows.Count).End(xlDown).row + 1
Range("B7").Select
ActiveCell.FormulaR1C1 = wsPay.Range("C" & Rows.Count).End(xlDown).row + 1
Range("H7").Select
ActiveCell.FormulaR1C1 = wsPay.Range("AJ" & Rows.Count).End(xlDown).row + 1
Range("K7").Select
ActiveCell.FormulaR1C1 = wsPay.Range("H" & Rows.Count).End(xlDown).row + 1
Range("B8").Select
ActiveCell.FormulaR1C1 = wsPay.Range("I" & Rows.Count).End(xlDown).row + 1
Range("H8").Select
ActiveCell.FormulaR1C1 = wsPay.Range("AK" & Rows.Count).End(xlDown).row + 1
Range("K8").Select
ActiveCell.FormulaR1C1 = wsPay.Range("F" & Rows.Count).End(xlDown).row + 1
in the loop, whereas the formula needed to return the corresponding cell data in that column range is not capturing.