Sub updateCP()
'
' update Macro
' Stop calculation
Application.Calculation = xlManual
Application.ScreenUpdating = False
'Unhide sheets
Sheets("Projects").Visible = True
Sheets("Master").Visible = True
Sheets("ProjectsCalc").Visible = True
Sheets("CP import").Visible = True
'Clearing vlookup
Sheets("Projects").Select
Range("L4:AS4").Select
Selection.ClearContents
'Updating team projects and availability
Sheets("Pr Develop").Select
Range("A3:BZ10000").Select
Selection.ClearContents
Range("A3").Select
[COLOR=#ff0000] Workbooks.Open Filename:= _[/COLOR]
[COLOR=#ff0000] "H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\Product development.xlsm"[/COLOR]
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Projects").Select
Range("A3:BZ10000").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets("CP import").Select
Range("B2:BZ2500").Select
Selection.ClearContents
Range("A2").Select
Windows("Product development.xlsm").Activate
Sheets("Resource input").Select
Range("B3:BZ590").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("CP import").Select
Range("B1043").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets("Pr Pack").Select
Range("A3:BZ10000").Select
Selection.ClearContents
Range("A3").Select
Workbooks.Open Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\Packaging.xlsm"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Projects").Select
Range("A3:BZ10000").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets("CP import").Select
Range("B595").Select
Windows("Packaging.xlsm").Activate
Sheets("Resource input").Select
Range("B3:BZ450").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("CP import").Select
Range("B595").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets("Pr CAP 3").Select
Range("A3:BZ10000").Select
Selection.ClearContents
Range("A3").Select
Workbooks.Open Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\CAP 3.xlsm"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Projects").Select
Range("A3:BZ10000").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A3").Select
Sheets("CP import").Select
Range("B3").Select
Windows("CAP 3.xlsm").Activate
Sheets("Resource input").Select
Range("B3:BZ593").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("CP import").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("DemVsRes").Select
Range("B3").Select
' update MASTER
Application.Calculation = xlAutomatic
Sheets("Master").Select
Range("A2:AH10000").Select
Selection.ClearContents
Range("AI3:AI10000").Select
Selection.ClearContents
Range("A2").Select
Workbooks.Open Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Planning 2Y+C\Project Tracker\Master File.xlsm"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("TRP Input").Select
Range("A2:AH10000").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AI2").Select
lRw = Range("A" & Rows.Count).End(xlUp).Row
Range("AI2", "AI" & lRw).FillDown
Range("A1:AI10000").Select
ActiveWorkbook.Worksheets("Master").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Master").Sort.SortFields.Add Key:=Range("A2:A10000") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Master").Sort
.SetRange Range("A1:AI10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select
' Update 8 projects
Application.DisplayAlerts = False
' Cap 3
Windows("CAP 3.xlsm").Activate
If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If
ActiveWorkbook.Unprotect "planning"
Sheets("8 projects").Visible = True
Sheets("8 projects").Select
Range("A2:E49").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("8 projects").Select
Range("A2:E49").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("CAP 3.xlsm").Activate
Sheets("8 projects").Visible = False
ActiveWorkbook.Protect "planning", Structure:=False, Windows:=False
ActiveWorkbook.KeepChangeHistory = True
ActiveWorkbook.SaveAs Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\CAP 3.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, AccessMode:=xlShared
Windows("Reporting file - Central Product.xlsm").Activate
Range("B2").Select
' Packaging
Windows("Packaging.xlsm").Activate
If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If
ActiveWorkbook.Unprotect "planning"
Sheets("8 projects").Visible = True
Sheets("8 projects").Select
Range("A2:E145").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("8 projects").Select
Range("A50:E193").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Packaging.xlsm").Activate
Sheets("8 projects").Visible = False
ActiveWorkbook.Protect "planning", Structure:=False, Windows:=False
ActiveWorkbook.KeepChangeHistory = True
ActiveWorkbook.SaveAs Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\Packaging.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, AccessMode:=xlShared
Windows("Reporting file - Central Product.xlsm").Activate
Range("B2").Select
' Product Development
Windows("Product development.xlsm").Activate
If ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.ExclusiveAccess
End If
ActiveWorkbook.Unprotect "planning"
Sheets("8 projects").Visible = True
Sheets("8 projects").Select
Range("A2:E209").Select
Selection.Copy
Windows("Reporting file - Central Product.xlsm").Activate
Sheets("8 projects").Select
Range("A194:E401").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("Product Development.xlsm").Activate
Sheets("8 projects").Visible = False
ActiveWorkbook.Protect "planning", Structure:=False, Windows:=False
ActiveWorkbook.KeepChangeHistory = True
ActiveWorkbook.SaveAs Filename:= _
"H:\Group\R&D\CP&I RD158\Develop\General\Technical Resource Planning - input files\Product development.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, AccessMode:=xlShared
Windows("Reporting file - Central Product.xlsm").Activate
Range("B2").Select
' Sorting
ActiveWorkbook.Worksheets("8 projects").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("8 projects").AutoFilter.Sort.SortFields.Add Key:= _
Range("B1:B401"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("8 projects").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.DisplayAlerts = True
' Close windows
Application.DisplayAlerts = False
Windows("Master File.xlsm").Close
Windows("Product development.xlsm").Close
Windows("Packaging.xlsm").Close
Windows("CAP 3.xlsm").Close
Application.DisplayAlerts = True
Application.Calculation = xlManual
' update Projects
Sheets("Projects").Select
Range("A3:K15000").Select
Selection.ClearContents
Sheets("Pr Develop").Select
Range("A3:I4999").Select
Selection.Copy
Sheets("Projects").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Pr CAP 3").Select
Range("A3:I4999").Select
Selection.Copy
Sheets("Projects").Select
Range("A3").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Pr Pack").Select
Range("A3:I4999").Select
Selection.Copy
Sheets("Projects").Select
Range("A3").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.Calculation = xlAutomatic
Sheets("Projects").Select
Range("L3:AS3").Select
lRw = Range("A" & Rows.Count).End(xlUp).Row
Range("L3:AS3", "L" & lRw).FillDown
ActiveSheet.Range("$A$3:$I$14996").removeduplicates Columns:=1, Header:= _
xlNo
' update New Projects
Sheets("New Projects").Select
Range("A2:BZ10000").Select
Selection.ClearContents
Sheets("Master").Select
Range("A2:BV2548").Select
Selection.Copy
Sheets("New Projects").Select
Range("A2").Select
ActiveSheet.Paste
ActiveSheet.Range("$A$1:$AI$10000").AutoFilter Field:=35, Criteria1:="Yes"
Range("A1").Select
ActiveSheet.Range(Cells(2, 1), Cells(1000, 35)).Select
Selection.ClearContents
ActiveSheet.Range("$A$1:$AI$10000").AutoFilter Field:=35, Criteria1:="No"
ActiveWorkbook.Worksheets("Master").Sort.SortFields.Add Key:=Range("A2:A10000") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Master").Sort
.SetRange Range("A1:AI10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Update projects timeline review and past to dashboard
Sheets("Projects timeline review").Select
ActiveSheet.Range("$A$1:$BC$10000").AutoFilter Field:=55
Sheets("ProjectsCalc").Select
Range("A3:BC10000").Select
Selection.Copy
Sheets("Projects timeline review").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Range("$A$1:$BC$10000").AutoFilter Field:=55, Criteria1:="="
Range("A2").Select
ActiveSheet.Range(Cells(3, 1), Cells(10000, 55)).Select
Selection.ClearContents
ActiveSheet.Range("$A$1:$BC$10000").AutoFilter Field:=55
ActiveWorkbook.Worksheets("Projects timeline review").Sort.SortFields.Add Key _
:=Range("BC3:BC10000"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Projects timeline review").Sort
.SetRange Range("A3:BC10000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$BC$10000").AutoFilter Field:=55, Criteria1:="<>"
' Hide sheets
Sheets("Projects").Visible = False
Sheets("Master").Visible = False
Sheets("ProjectsCalc").Visible = False
Sheets("CP import").Visible = False
Application.ScreenUpdating = True
Sheets("DemVsRes").Select
End Sub