So, I've been working on this for quite a while with no luck. All it's supposed to do is merge two files together. It works until I add a new parameter (location). I've tried several variations on the code with no luck. Do I have to add another VLOOKUP?
Code:
'Opening Source Files
Workbooks.Open Filename:="xxx.csv"
Workbooks.Open Filename:="xxxx.csv"
' Merging Files
Workbooks("Mantas User Roles.xls").Sheets("Mantas_User_Roles").Copy After:=Workbooks("a-AMLxx-MantasGrp.csv").Sheets("a-AMLxx-MantasGrp")
Workbooks("a-AMLxx-MantasGrp.csv").Sheets("a-AMLxx-MantasGrp").Activate
Columns("C:C").Cut
Columns("A:A").Insert Shift:=xlToRight
Columns("B:B").Cut
Columns("E:E").Insert Shift:=xlToRight
LastRow = Sheets("a-AMLxx-MantasGrp").Cells(Rows.Count, 4).End(xlUp).Row
lastrow2 = Sheets("Mantas_User_Roles").Cells(Rows.Count, 1).End(xlUp).Row
Range("E2:E" & LastRow).Formula = "=VLOOKUP(C2,Mantas_User_Roles!$A$2:$E$" & lastrow2 & ",2,FALSE)"
Range("F2:F" & LastRow).Formula = "=VLOOKUP(C2,Mantas_User_Roles!$A$2:$E$" & lastrow2 & ",3,FALSE)"
Range("G2:G" & LastRow).Formula = "=VLOOKUP(C2,Mantas_User_Roles!$A$2:$E$" & lastrow2 & ",4,FALSE)"
Range("H2:H" & LastRow).Formula = "=VLOOKUP(C2,Mantas_User_Roles!$A$2:$E$" & lastrow2 & ",5,FALSE)"
Workbooks("a-AMLxx-MantasGrp.csv").Sheets("a-AMLxx-MantasGrp").Range("E2:H" & LastRow).Copy
Workbooks("a-AMLxx-MantasGrp.csv").Sheets("a-AMLxx-MantasGrp").Range("I2:L" & LastRow).PasteSpecial xlPasteValues
Workbooks("a-AMLxx-MantasGrp.csv").Sheets("a-AMLxx-MantasGrp").Columns("F:I").EntireColumn.Delete
Range("A1").Formula = "Access Approver"
Range("B1").Formula = "User Name"
Range("C1").Formula = "User ID"
Range("D1").Formula = "Cost Center"
Range("E1").Formula = "Location"
Range("F1").Formula = "Role 1"
Range("G1").Formula = "Role 2"
Range("H1").Formula = "Role 3"
Range("I1").Formula = "Role 4"
Range("J1").Formula = "Access Approved:"
Range("K1").Formula = "SAR# of Request Submitted:"