Reputation: 31
I am entering in serial numbers into excel, I already have data validation enabled and it works charmingly. However most of the users who use the system when scanning go by the beep the scanner makes even if it does not enter data into the cell itself and just go their merry way, which makes for a missed scan. I am trying to get a simple VBA or formula for an entire column that when data is entered into that column it will make a default windows sound letting the user know that data was successfully entered into that cell. Any help would be appreciated, thank you ahead of time. Keep in mind i've tried using values such as =If (B3>30, BeepOnce(),"") , however our serial numbers contain both letters and numbers i.e G18BB0070988019282
Upvotes: 0
Views: 812
Reputation: 3877
Place this in your worksheet's module to monitor column B for any changes.
Depending on the length of the changed value, it plays different sounds:
Code with all 3 variants:
Option Explicit
Private Declare PtrSafe Function KernelBeep Lib "kernel32" Alias "Beep" _
(ByVal dwFreq As Long, _
ByVal dwDuration As Long) As Long
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MonitoredArea As Range
Set MonitoredArea = Intersect(Target, Me.Range("B:B"))
If Not MonitoredArea Is Nothing Then
If Len(Target.Value) > 10 Then
'Beep ' Excel VBA Standard
KernelBeep 4000, 100 ' frequency, duration
'Application.Speech.Speak "ok", True
Else
KernelBeep 600, 100
KernelBeep 600, 100
KernelBeep 600, 100
'Application.Speech.Speak "a", True
End If
End If
End Sub
Upvotes: 1