Sub VndrCoding_Setup()
'for adding all the columns and basic formulas
Dim Headers() As Variant
Dim DeptID As Integer
Dim PAC As Integer
SpeedOn
Headers() = Array("DeptID", "PAC", "ProjID", "PCA", "Approp", "MM/YY", "Acct", "Cost w Admin Fee", "BA")
Dim LastRow As Long
DeptID = ActiveCell.Column
With ActiveSheet
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
With ActiveCell
'Apply Headers
ActiveSheet.Cells(.Row, .Column).Resize(1, UBound(Headers) - LBound(Headers) + 1) = Headers
ActiveSheet.Cells(.Row, .Column).Resize(1, UBound(Headers) - LBound(Headers) + 1).Font.Bold = True
'Formulas for DeptID and PAC
.Offset(1, 0).Resize(LastRow - .Row).FormulaR1C1 = _
"=LEFT(VLOOKUP(TEXT(RC7,""00000000000""),'\\121001fs01\share10011\Budget\Active Position Reports\2020\11_2019\[FY 20 Active Positions - Annualized Costs - 11-15-19 - New Format.xlsx]APR Data'!C5:C46,4,FALSE),8)"
.Offset(1, 1).Resize(LastRow - .Row).FormulaR1C1 = _
"=LEFT(VLOOKUP(TEXT(RC7,""00000000000""),'\\121001fs01\share10011\Budget\\Active Position Reports\2020\11_2019\[FY 20 Active Positions - Annualized Costs - 11-15-19 - New Format.xlsx]APR Data'!C5:C46,39,FALSE),8)"
'ProjID, PCA, Approp
.Offset(1, 2).Resize(LastRow - .Row).FormulaR1C1 = _
"=VLOOKUP(RC" & DeptID + 1 & ",'\\121001fs01\share10011\Accounting\Z4116\[Coding Workbook.xlsm]FY20 All Dept Coding'!C8:C11,2,FALSE)"
.Offset(1, 3).Resize(LastRow - .Row).FormulaR1C1 = _
"=VLOOKUP(RC" & DeptID + 1 & ",'\\121001fs01\share10011\Accounting\Z4116\[Coding Workbook.xlsm]FY20 All Dept Coding'!C8:C11,3,FALSE)"
.Offset(1, 4).Resize(LastRow - .Row).FormulaR1C1 = _
"=VLOOKUP(RC" & DeptID + 1 & ",'\\121001fs01\share10011\Accounting\Z4116\[Coding Workbook.xlsm]FY20 All Dept Coding'!C8:C11,4,FALSE)"
'All the Rest
.Offset(1, 5).Resize(LastRow - .Row).FormulaR1C1 = "=TEXT(RC[-22],""mm/yy"")"
.Offset(1, 6).Resize(LastRow - .Row).FormulaR1C1 = "729905"
.Offset(1, 7).Resize(LastRow - .Row).FormulaR1C1 = "=ROUND(RC[-17]*1.1,2)"
.Offset(-1, 7).FormulaR1C1 = "=SUM(R[2]C:R[" & LastRow & "]C)"
.Offset(1, 8).Resize(LastRow - .Row).FormulaR1C1 = _
"=VLOOKUP(RC" & DeptID & ",'\\12fs01\share10011\Accounting\Z4116\[Coding Workbook.xlsm]FY20 All Dept Coding'!C3:C5,3,FALSE)"
End With
Range(ActiveCell, ActiveCell.End(xlToRight)).EntireColumn.AutoFit
End With
SpeedOff
End Sub
Bookmarks