Code gives Runtime Error 13

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Target.Range("A1") Then
MsgBox "Please Highlight Cell A1 Before Calculating Lexical Diversity"

End If

End Sub

How can I fix this?

Almir's picture

Change Target.Range("A1") to Target.Address = "$A$1"

Hi dragonv29, try this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Target.Address = "$A$1" Then
MsgBox "Please Highlight Cell A1 Before Calculating Lexical Diversity"
End If
End Sub