Hi Monu,
Ok, master row will only get deleted when the value can't be found on the other project sheet.
In addition, changing a value in column A will not only update the master sheet, but also checks if the value needs to be changed on the other project sheets as well.
The same goes for column B values.
Pay attention to the green text in the beginning of the code, as you will need to change the sheet names of the other project sheet names. This code is for the sheet Project1. So the other 2 sheet names are "Project2" and "Project3". When you paste the code in sheet Project2, you will need to change the 2 into a 1 so it reads: "Project1" and "Project3".
Here is the code:
Dim aVal As String
Private Sub Worksheet_Change(ByVal Target As Range)
Dim mFind As Range
Dim keepRow As Boolean
Dim pSheetA, pSheetB As String
'This is the code for the sheet "Project1", below you will find the names of the other 2 project sheets.
'These are necessary to make changes in those sheets. Make sure you change them, when you use the code for the other 2 project sheets.
pSheetA = "Project2"
pSheetB = "Project3"
If Target.Cells.Count > 1 Then Exit Sub
With Sheets("Personnel list & effort ")
If aVal = vbNullString Then
If Not Intersect(Target, Columns("A")) Is Nothing Then
Set mFind = .Columns("A").Find(Target.Value)
If mFind Is Nothing Then
.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Target.Value
End If
End If
If Not Intersect(Target, Columns("B")) Is Nothing Then
Set mFind = .Columns("A").Find(Target.Offset(0, -1).Value)
mFind.Offset(0, 1).Value = Target.Value
.Select
If mFind.Row > 2 Then
.Range(.Cells(mFind.Row - 1, "C"), .Cells(mFind.Row - 1, "E")).AutoFill Destination:=.Range(.Cells(mFind.Row - 1, "C"), .Cells(mFind.Row, "E"))
ElseIf mFind.Row = 2 Then
.Range(.Cells(mFind.Row + 1, "C"), .Cells(mFind.Row + 1, "E")).AutoFill Destination:=.Range(.Cells(mFind.Row + 1, "C"), .Cells(mFind.Row, "E"))
End If
Set mFind = Sheets(pSheetA).Columns("A").Find(Target.Offset(0, -1).Value)
If Not mFind Is Nothing Then mFind.Offset(0, 1).Value = Target.Value
Set mFind = Sheets(pSheetB).Columns("A").Find(Target.Offset(0, -1).Value)
If Not mFind Is Nothing Then mFind.Offset(0, 1).Value = Target.Value
End If
Else
If Target.Value <> vbNullString Then
If Not Intersect(Target, Columns("A")) Is Nothing Then
Set mFind = .Columns("A").Find(aVal)
If mFind Is Nothing Then
.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Target.Value
Else
mFind.Value = Target.Value
Set mFind = Sheets(pSheetA).Columns("A").Find(aVal)
If Not mFind Is Nothing Then mFind.Value = Target.Value
Set mFind = Sheets(pSheetB).Columns("A").Find(aVal)
If Not mFind Is Nothing Then mFind.Value = Target.Value
End If
End If
Else
If Not Intersect(Target, Columns("A")) Is Nothing Then
Set mFind = Sheets(pSheetA).Columns("A").Find(aVal)
If Not mFind Is Nothing Then keepRow = True
Set mFind = Sheets(pSheetB).Columns("A").Find(aVal)
If Not mFind Is Nothing Then keepRow = True
If keepRow = False Then
Set mFind = .Columns("A").Find(aVal)
.Rows(mFind.Row).Delete
End If
keepRow = False
End If
End If
End If
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Columns("A")) Is Nothing Then aVal = Target.Value
End Sub
Best regards,
Trowa