You are on page 1of 6

Global

Global
Global
Global
Global

PRJ_ID As Dictionary
ENG_ID As Dictionary
LstPRJ As Range
LstPRJ_EAPS As Range
LstENG As Range

'''''''''''''''''''''''''''''''''Initiation PRJ IDS, ENG IDS, EMP_IDs''''''''''


'''''''''''''''''
Sub Initial()
Dim MyFile As String
Dim wbName As Workbook
Dim PRJ_RNG_ID As Dictionary
Set PRJ_RNG_ID = New Dictionary
Dim sh As Range
Dim PRJ_RNG As Range
MyFile = Application.GetOpenFilename()
Set wbName = Workbooks.Open(MyFile)
wbName.Activate
k = ActiveWorkbook.Worksheets.Count
For i = 0 To k + 1
If InStr(Worksheets(i + 1).Name, "SAP") <> 0 Then
Worksheets(i + 1).Activate
Range(Cells(4, 3), Cells(Cells(Rows.Count, 3).End(xlUp).Row, 3)).Select
Set PRJ_RNG = Range(Cells(4, 3), Cells(Cells(Rows.Count, 3).End(xlUp).Ro
w, 3))
For Each psh In PRJ_RNG
If psh.Value <> 0 Then
pp_s = psh.Value
If pp_s <> "" Then
PRJ_RNG_ID.Add pp_s, pp_s
End If
End If
Next
Exit For
End If
Next i
wbName.Close SaveChanges:=False
'''''''''''''''''''''''''''''''''''Setting PRJ Dictionaries'''''''''''''''''''''
'''''''''''''''''
Set PRJ_ID = New Dictionary
Dim pp As Range
Dim pp_k As String
Dim pp_v As Integer
Sheets("MainSh").Activate
Set LstPRJ = Sheets("MainSh").Range(Cells(5, 2), Cells(Cells(Rows.Count, 2).End(
xlUp).Row, 2))
For Each pp In LstPRJ
pp_k = pp.Value
pp_v = pp.Offset(0, 1)
If pp_k <> "" Then
PRJ_ID.Add pp_k, pp_v
End If
Next

For Each ks In PRJ_RNG_ID.Keys


If PRJ_ID.Exists(ks) Then
Else
s = s + 1
Cells(Cells(Rows.Count, 2).End(xlUp).Row + 1, 2) = ks
Cells(Cells(Rows.Count, 3).End(xlUp).Row + 1, 3) = PRJ_ID.Count + s
End If
Next
'''''''''''''''''''''''''''''''''''Setting ENG Dictionaries'''''''''''''''''''''
'''''''''''''''''
Set ENG_ID = New Dictionary
Dim ee As Range
Dim ee_k As String
Dim ee_v As Integer
Sheets("MainSh").Activate
Set LstENG = Sheets("MainSh").Range(Cells(5, 4), Cells(Cells(Rows.Count, 4).End(
xlUp).Row, 4))
For Each ee In LstENG
ee_k = ee.Value
ee_v = ee.Offset(0, 2)
If ee_k <> "" Then
ENG_ID.Add ee_k, ee_v
End If
Next
UsNm = Application.UserName
End Sub
Sub DTB()
Dim
Dim
Dim
Set

CdDate As Date
dd As Integer
ENGDT As Dictionary
ENGDT = New Dictionary

''''''''''''''''''''''''''''''''''' Eng List Ranges and Dictionary OF DTB Sheet'


''''''''''''''''''''''''''''''''''''''''''''
Dim LstEMP_ID As Range
Dim DT_ENG_ID As Dictionary
Set DT_ENG_ID = New Dictionary
Sheets("MainSh").Activate
Set LstEMP_ID = Sheets("MainSh").Range(Cells(5, 5), Cells(Cells(Rows.Count, 5).E
nd(xlUp).Row, 5))
Dim LstENG_DTB As Range
Sheets("DTB").Activate
Set LstENG_DTB = Sheets("DTB").Range(Cells(4, 2), Cells(Cells(Rows.Count, 2).End
(xlUp).Row, 2))
LstENG_DTB.Borders.LineStyle = xlContinuous
For Each ls In LstENG_DTB
If ls.Value <> 0 Then
DT_ENG_ID.Add ls.Value, ls.Offset(0, -1).Value
End If
Next

'''''''''''''''''''''''''''''
Ranges Created
''''''''''''''''''''''''''''''''''''''''''''

''''''''''

'''''''''''''''''''''''''''''''''' Adding Eng List Ranges '''''''''''''''''''


''''''''''''''''
Dim EngNm As String
For Each kys In ENG_ID.Keys
If DT_ENG_ID.Exists(kys) And DT_ENG_ID.Item(kys) = ENG_ID.Item(kys) Then
Else
Cells(Cells(Rows.Count, 2).End(xlUp).Row + 1, 2) = kys
Cells(Cells(Rows.Count, 1).End(xlUp).Row + 1, 1) = ENG_ID.Item(kys)
End If
Next
'''''''''''''''''''''''''''''''''' Adding Eng List Ranges Created ''''''''''''
''''''''''''''''

'''''''''''''''''''''''''''''''' Updating Date List in DTB Sheet


''''''''''
CdDate = Date
Sheets("DTB").Activate
Rows(2).ColumnWidth = 9
'LsEngCnt = LstENG.Count
NonEmptyRow = Cells(2, Columns.Count).End(xlToLeft).Column

EnDate = Cells(2, NonEmptyRow).Value


dd = EnDate - CdDate
If dd = 1 Then
k = NonEmptyRow + 2
CdDate = CdDate + 1
For i = 1 To 7
Range(Cells(2, k), Cells(2, k + 1)).Select
With Selection
.Merge
.Value = CdDate + i
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Borders.LineStyle = xlContinuous
.Offset(1, 0) = "Spent"
.Offset(1, 0).Select
Selection.Borders.LineStyle = xlContinuous
Selection.Offset(0, 1).Select
Selection.Borders.LineStyle = xlContinuous
Selection.Value = "Billed"
End With
k = Cells(2, Columns.Count).End(xlToLeft).Column + 2
Next i
End If

''''''''''''

If dd = 6 Then
Range(Cells(2, 3), Cells(2, 20)).EntireColumn.Delete
End If
End Sub

Sub Date_Range()
Dim
Dim
Dim
Dim
Dim
Dim
Set
Dim
Set
Dim
Set

CrDate As Date
EnDate As Date
LsEngCnt As Integer
NonEmptyRow As Integer
dd As Integer
PRJDict As Dictionary
PRJDict = New Dictionary
FN As Dictionary
FN = New Dictionary
DT As Dictionary
DT = New Dictionary

'''''''''''''''''''''''''''''
''''''''''''''''''

Creating Ranges

''''''''''

'''''''''''''''''''''''''''''
Creating PRJ Dictionaries with Mapping I
D Ranges
''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''
PRJ Dictionaries with Mapping ID Ranges
Created
''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''
Creating ENG Dictionaries with Mapping I
D Ranges
''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''
Creating ENG Dictionaries with Mapping I
D Ranges
''''''''''''''''''''''''''''
Dim LstEMP_ID As Range
Sheets("MainSh").Activate
Set LstEMP_ID = Sheets("MainSh").Range(Cells(5, 5), Cells(Cells(Rows.Count, 5).E
nd(xlUp).Row, 5))
Dim LstEMP_MPID As Range
Sheets("MainSh").Activate
Set LstEMP_MPID = Sheets("MainSh").Range(Cells(5, 6), Cells(Cells(Rows.Count, 6)
.End(xlUp).Row, 6))
'''''''''''''''''''''''''''''
''''''''''''''''''

Ranges Created

''''''''''

''''''''''''''''''''''''''''''''' PRJ List Ranges ''''''''''''''''''''''''''


'''''''''
Dim LsPRJs As Range
Dim ls As Range
Sheets("Entry").Activate
Set LsPRJs = Range(Cells(3, 6), Cells(3, Cells(3, Columns.Count).End(xlToLeft).C
olumn))
LsPRJs.Select

For Each ls In LsPRJs


If ls <> "" Then
dl = ls.Value
PRJDict.Add dl, 1
End If
Next ls
''''''''''''''''' PRJ List Ranges Added PRJ Dictionary is also added
'''''''''

'''''''

'''''''''''''''''''''''''''''''''Adding New PRJ List Ranges in the sheet''''''''


'''''''''''''''''''''
For Each kys In PRJ_ID.Keys
kl = kys
If Not PRJDict.Exists(kl) Then
Sheets("Entry").Activate
Range(Cells(3, Cells(3, Columns.Count).End(xlToLeft).Column + 2), Cells(
3, Cells(3, Columns.Count).End(xlToLeft).Column + 3)).Select
Selection.Merge
Selection.Borders.LineStyle = xlContinuous
Selection.Value = kys
Selection.HorizontalAlignment = xlCenter
Selection.Offset(1, 0).Select
Selection.Borders.LineStyle = xlContinuous
Selection.Value = "Spent"
Selection.ColumnWidth = 16
Selection.HorizontalAlignment = xlCenter
Selection.Offset(0, 1).Select
Selection.Borders.LineStyle = xlContinuous
Selection.Value = "Billed"
Selection.ColumnWidth = 16
Selection.HorizontalAlignment = xlCenter
End If
Next
'''''''''''''''''''''''''''''''''New PRJ List Ranges in the sheet Added'''''''''
''''''''''''''''''''

'''''''''''''''''''''''''''''''' Updating Date List in Entry Sheet


''''''''''''
CrDate = Date + 6
Sheets("Entry").Activate
LsEngCnt = ENG_ID.Count
NonEmptyRow = Cells(Rows.Count, 2).End(xlUp).Row
EnDate = Cells(NonEmptyRow, 2).Value
dd = EnDate - CrDate
If dd = 1 Then
k = NonEmptyRow + LsEngCnt
l = k + LsEngCnt - 1
CrDate = CrDate + 2

''''''''''

For i = 0 To 6
Range(Cells(k, 2), Cells(l, 2)).Select
Selection.Merge
Selection.Value = CrDate + i
Selection.HorizontalAlignment = xlCenter
Selection.VerticalAlignment = xlCenter
Selection.Borders.LineStyle = xlContinuous
j = k
For Each kys In ENG_ID.Keys
Cells(j, 3).Borders.LineStyle = xlContinuous
Cells(j, 3).Value = kys
j = j + 1
Next
NonEmptyRow = Cells(Rows.Count, 2).End(xlUp).Row + 1
k = NonEmptyRow + LsEngCnt - 1
l = k + LsEngCnt - 1
Next i
End If
If dd = 6 Then
k = 5
l = k + LsEngCnt - 1
For i = 1 To 7
Range(Cells(k, 2), Cells(l, 2)).Select
Selection.EntireRow.Delete
'''''''''''''''''''''''''''''''''''''Here You Enter the Requirement on Wedne
sday''''''''''''''
k = 5
l = k + LsEngCnt - 1
Next i
End If
'''''''''''''''''''''''''''''''' Date List in Entry Sheet Updated ''''''''''''
''''''''''''
'''''''''''''''''''
Updating the New Engineer if Included in the recent DATE
List Ranges
'''''''''''''''''
s = Cells(Rows.Count, 2).End(xlUp).Row
Range(Cells(5, 2), Cells(Cells(s, 2))).Select
Set LsDTRngs = Range(Cells(5, 2), Cells(Cells(Rows.Count, 2).End(xlUp).Row, 2))
'''''''''''''''''''
New Engineer if Included in the recent DATE List Ranges i
s Updated
'''''''''''''''''''
End Sub

You might also like