Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 12/16/2020 1:37:57 PM EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 1 Then
If Target.Value = Target.Offset(-1).Value Then MsgBox "You entered the value " & Target.Value & " In the cell above"
End If
End Sub
That is because you changed my script. What do you want the message to say?Hi there,
Thanks a lot for the solution but when the cell value is entered ,it is asking for debugging as I enter the value in the first cell.Below is the screen shot for your reference.
View attachment 28181
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 12/17/2020 4:32:32 PM EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 1 Then
If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
End If
End Sub
I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for meTry this:
Not sure why you want it this way but here is what you were trying to do.
VBA Code:Private Sub Worksheet_Change(ByVal Target As Range) 'Modified 12/17/2020 4:32:32 PM EST If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub If Target.Column = 1 Then If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above" End If End Sub
If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for me
VBA Code:If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
I test all my scripts and this script works. Target.Offset(-1)I think you have mistake first you specific the column a then offset -1 this means move before column a there is not existed column before a am I right or wrong? your code doesn't work at all even if select another column like in post #3 you have a typo should be put comma this works for me
VBA Code:If Target.Value = Target.Offset(,-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 12/17/2020 5:08:12 PM EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 1 And Target.Row > 1 Then
If Target.Value = Target.Offset(-1).Value Then MsgBox "Different Pairs Found" & vbNewLine & "In the cells above"
End If
End Sub