I believe this will be the Final Code, Replace the previous code with the below:-
Dim vPreValue As Variant
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("B:B")) Is Nothing Then Exit Sub
vPreValue = Target.Value
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Target, Range("B:C")) Is Nothing Then Exit Sub
Dim Ws As Worksheet, nEndRw As Long, vColB As Variant, i As Long
On Error GoTo ErrorOccurred
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each Ws In ThisWorkbook.Sheets
With Ws
nEndRw = .Cells(Rows.Count, "B").End(xlUp).Row
If Target.Column = 2 Then
vColB = vPreValue
Else
vColB = Target.Offset(0, -1).Value
End If
For i = 1 To nEndRw
If .Cells(i, "B").Value <> "" Then
If .Cells(i, "B").Value = vColB Then
.Cells(i, Target.Column) = Target.Formula
End If
End If
Next i
End With
Next Ws
Application.EnableEvents = True
Application.ScreenUpdating = True
Exit Sub
ErrorOccurred:
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "An Error Occurred", vbCritical, "Error Alert"
End Sub
Bookmarks