Sub PasteCellValue()
Application.ScreenUpdating = False
Dim rng As Range, rName1 As Range, rName2 As Range, sAddr As String, x As Long, sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
For Each rng In sh1.Range("D1:H1")
Select Case rng.Value
Case "JDG"
Set rName1 = sh2.Range("B:B").Find("JDG:", LookIn:=xlValues, lookat:=xlWhole)
If Not rName1 Is Nothing Then
sAddr = rName1.Address
Do
Set rName2 = sh1.Range("B:B").Find(rName1.Offset(-4, -1).Value)
If Not rName2 Is Nothing And sh1.Cells(rName2.Row, rng.Column) <> rName1.Offset(0, 2) Then
With sh1
.Cells(rName2.Row, rng.Column) = rName1.Offset(0, 2)
.Cells(rName2.Row, rng.Column).Interior.ColorIndex = 6
End With
End If
Set rName1 = sh2.Range("B:B").Find("JDG:", after:=rName1, LookIn:=xlValues, lookat:=xlWhole)
Loop While rName1.Address <> sAddr
sAddr = ""
End If
Case "CIVILS"
Set rName1 = sh2.Range("B:B").Find("civil:", LookIn:=xlValues, lookat:=xlWhole)
If Not rName1 Is Nothing Then
sAddr = rName1.Address
Do
Set rName2 = sh1.Range("B:B").Find(rName1.Offset(-1, -1).Value)
If Not rName2 Is Nothing And sh1.Cells(rName2.Row, rng.Column) <> rName1.Offset(0, 2) Then
With sh1
.Cells(rName2.Row, rng.Column) = rName1.Offset(0, 2)
.Cells(rName2.Row, rng.Column).Interior.ColorIndex = 6
End With
End If
Set rName1 = sh2.Range("B:B").Find("civil:", after:=rName1, LookIn:=xlValues, lookat:=xlWhole)
Loop While rName1.Address <> sAddr
sAddr = ""
End If
Case "PROBATES"
Set rName1 = sh2.Range("B:B").Find("probate:", LookIn:=xlValues, lookat:=xlWhole)
If Not rName1 Is Nothing Then
sAddr = rName1.Address
Do
Set rName2 = sh1.Range("B:B").Find(rName1.Offset(-3, -1).Value)
If Not rName2 Is Nothing And sh1.Cells(rName2.Row, rng.Column) <> rName1.Offset(0, 2) Then
With sh1
.Cells(rName2.Row, rng.Column) = rName1.Offset(0, 2)
.Cells(rName2.Row, rng.Column).Interior.ColorIndex = 6
End With
End If
Set rName1 = sh2.Range("B:B").Find("probate:", after:=rName1, LookIn:=xlValues, lookat:=xlWhole)
Loop While rName1.Address <> sAddr
sAddr = ""
End If
Case "BKY"
Set rName1 = sh2.Range("B:B").Find("Bankruptcy", LookIn:=xlValues, lookat:=xlWhole)
If Not rName1 Is Nothing Then
For x = 1 To 4
Set rName2 = sh1.Range("B:B").Find(rName1.Offset(x, -1).Value)
If Not rName2 Is Nothing And sh1.Cells(rName2.Row, rng.Column) <> rName1.Offset(x, 2) Then
With sh1
.Cells(rName2.Row, rng.Column) = rName1.Offset(x, 2)
.Cells(rName2.Row, rng.Column).Interior.ColorIndex = 6
End With
End If
Next x
End If
Case "FEDJDG"
Set rName1 = sh2.Range("B:B").Find("FDG:", LookIn:=xlValues, lookat:=xlWhole)
If Not rName1 Is Nothing Then
sAddr = rName1.Address
Do
Set rName2 = sh1.Range("B:B").Find(rName1.Offset(-1, -1).Value)
If Not rName2 Is Nothing And sh1.Cells(rName2.Row, rng.Column) <> rName1.Offset(0, 2) Then
With sh1
.Cells(rName2.Row, rng.Column) = rName1.Offset(0, 2)
.Cells(rName2.Row, rng.Column).Interior.ColorIndex = 6
End With
End If
Set rName1 = sh2.Range("B:B").Find("FDG:", after:=rName1, LookIn:=xlValues, lookat:=xlWhole)
Loop While rName1.Address <> sAddr
sAddr = ""
End If
End Select
Next rng
Application.ScreenUpdating = True
End Sub