You do not need an API for this
You can also use Beep .
Sub Sample() Beep End Sub
Example
WAY 1
This code will be run if there are changes in the document anywhere
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim Cell As Range Dim CheckRange As Range Set CheckRange = Range("C:C") For Each Cell In CheckRange If Cell.Text = "#N/A" Then Beep Exit For End If Next End Sub
WAY 2
Alternative to above code
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim Cell As Range For Each Cell In Columns(3) On Error Resume Next If CVErr(Cell) = CVErr(2042) Then Beep Exit For End If On Error GoTo 0 Next End Sub
Way 3
If you want to check Col C only if there is a manual shift anywhere in Col C
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim Cell As Range If Not Intersect(Target, Columns(3)) Is Nothing Then For Each Cell In Columns(3) On Error Resume Next If CVErr(Cell) = CVErr(2042) Then Beep Exit For End If On Error GoTo 0 Next End If End Sub
Method 4
If you want to check a specific cell, if there is a manual change in this cell.
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim Cell As Range If Not Intersect(Target, Columns(3)) Is Nothing Then On Error Resume Next If CVErr(Target) = CVErr(2042) Then Beep Exit Sub End If On Error GoTo 0 End If End Sub
Path 5
Change path 4
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim Cell As Range If Not Intersect(Target, Columns(3)) Is Nothing Then If Target.Text = "#N/A" Then Beep Exit Sub End If End If End Sub
FOLLOWUP (Add Comment)
The active cell will be in column b, so it should check the one on the right in column d - Sam Cousins 1 min. back
I think you meant Col C, not Col D. To do this, use Worksheet_SelectionChange to
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Columns(2)) Is Nothing Then If Target.Offset(, 1).Text = "#N/A" Then Beep End If End If End Sub