NoobishNewb
New Member
- Joined
- Jun 1, 2018
- Messages
- 3
Hi all,
I would like to know how to make excel play a sound when a specific change occurs.
For example, I have a range of cells (F6 to F50) with formula within the cells. They are blank at first (which is normal). When the stock market moves, some of the cells (say F8 and F25) are "Triggered" based on the formula and play a sound accordingly. As the price of the stock changes, cell F8 changes from "Triggered" back to blank. However, because F25 still remains as "Triggered", excel plays a sound again.
I would like excel to play a sound when the cell changes from blank to "Triggered". But when the cell changes from "Triggered" back to blank, there should not be a sound even though there are other cells within F6 to F50 with the word "Triggered".
Please see below for what I have tried. (Btw I am a newbie in VBA).
Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim CheckRange As Range
Dim PlaySound As Boolean
Set CheckRange = Range("F6:F50")
If Not Intersect(Target, CheckRange) Is Nothing Then
For Each Cell In CheckRange
If Cell.Value = "Triggered" Then
PlaySound = True
End If
Next
If PlaySound Then
Call PlayTrigger
End If
End If
End Sub
I would like to know how to make excel play a sound when a specific change occurs.
For example, I have a range of cells (F6 to F50) with formula within the cells. They are blank at first (which is normal). When the stock market moves, some of the cells (say F8 and F25) are "Triggered" based on the formula and play a sound accordingly. As the price of the stock changes, cell F8 changes from "Triggered" back to blank. However, because F25 still remains as "Triggered", excel plays a sound again.
I would like excel to play a sound when the cell changes from blank to "Triggered". But when the cell changes from "Triggered" back to blank, there should not be a sound even though there are other cells within F6 to F50 with the word "Triggered".
Please see below for what I have tried. (Btw I am a newbie in VBA).
Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim CheckRange As Range
Dim PlaySound As Boolean
Set CheckRange = Range("F6:F50")
If Not Intersect(Target, CheckRange) Is Nothing Then
For Each Cell In CheckRange
If Cell.Value = "Triggered" Then
PlaySound = True
End If
Next
If PlaySound Then
Call PlayTrigger
End If
End If
End Sub