1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| Dim CDWS_Input As String
Dim Workfile, WB_CDWS_Relationship As Workbook
Dim C2 As Range
Set Workfile = ThisWorkbook
CurrentpAth = ActiveWorkbook.Path
Set ObjExcel = CreateObject("Excel.Application")
ObjExcel.Visible = False
'Custom Filter to help the user to select the right file :
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "*C-DWS*Relationship*report*", "*.xl*;*.xslx;*.xlsm;*.xlsb;*.xlam;*.xltx;*.xltm;*.xls;*.xla;*.xlt;*.xlm;*.xlw"
.Title = "Select the C-DWS Relationship report input file of the Month"
.InitialFileName = CurrentpAth & "\" & "*C-DWS*Relationship*report*"
.Show
'Open the file selected & links update desactivation
If .SelectedItems.Count Then
CDWS_Relationship_Input = .SelectedItems(1) 'Full path retrieving
Set WB_CDWS_Relationship = Workbooks.Open(Filename:=CDWS_Relationship_Input, UpdateLinks:=xlUpdateLinskNever)
Else: Exit Sub
End If
End With
'CDWS RelationShip report last line detection
LineCDWSRelationship = WB_CDWS_Relationship.Sheets(1).Range("A2").End(xlDown).Row
'Define range in memory for execution speed
Set col_1 = Workfile.Sheets("ICT PBS mapping").Range("C7:C" & Range("C" & Rows.Count).End(xlDown).Row)
With WB_CDWS_Relationship.Sheets(1)
For I = 3 To LineCDWSRelationship
If Application.CountIf(col_1, .Range("B" & I).Value) <> 0 Then
Set C2 = Workfile.Sheets("ICT PBS mapping").Cells.Find(Range("B" & I).Value) 'Check the cells in ICT PBS Mapping where is the match
LineICTPBSMap_I = C2.Row 'Store the line from Full List
LineFullList = 2
' store data in variable
CWPProject = WB_CDWS_Relationship.Worksheets(1).Cells(I, 4)
CWPActivityID = WB_CDWS_Relationship.Worksheets(1).Cells(I, 5)
CWPActivityName = WB_CDWS_Relationship.Worksheets(1).Cells(I, 6)
Del_Master_ActivityID = Workfile.Sheets("ICT PBS mapping").Cells(LineICTPBSMap_I, 13)
Del_ProjectID = Workfile.Sheets("ICT PBS mapping").Cells(LineICTPBSMap_I, 14)
Del_IPL = Workfile.Sheets("ICT PBS mapping").Cells(LineICTPBSMap_I, 15)
Del_IPLName = Workfile.Sheets("ICT PBS mapping").Cells(LineICTPBSMap_I, 17)
'Provide these info in the sheet Full List
Workfile.Sheets("full list").Cells(LineFullList, 3) = CWPProject
Workfile.Sheets("full list").Cells(LineFullList, 4) = CWPActivityID
Workfile.Sheets("full list").Cells(LineFullList, 5) = CWPActivityName
Workfile.Sheets("full list").Cells(LineFullList, 10) = Del_Master_ActivityID
Workfile.Sheets("full list").Cells(LineFullList, 11) = Del_ProjectID
Workfile.Sheets("full list").Cells(LineFullList, 12) = Del_IPL
Workfile.Sheets("full list").Cells(LineFullList, 13) = Del_IPLName
End If
If Application.CountIf(col_1, .Range("C" & I).Value) = 0 Then GoTo Retour
LineFullList = LineFullList + 1
Retour:
Next
End With
End Sub |
Partager