Following on from a previous question #23367661. Two parts to this question:
1) I would like to use the If and Range functions with mulitiple ranges to return differet results. E.g: In excell if I write:
It will return the value in row 2 of the column that is >d1 in row 1. I.e. if b1 is >d1, then you get b2.
I tried to do this in VB and it didn't work. What do i need to do?
2) The second step is to also assign a wav file to each condition. E.g. if b1 is true i get chimes.wav, if c1 is true i get windows.wav etc....
So you get a different combinations of a sound and a message box for each of the 3 cells in the range a1:c1.
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Public StopCode As Boolean
Public Sub PlayFile(wFile As String)
Call PlaySound(wFile, 0&, SND_ASYNC Or SND_FILENAME)
If StopCode = True Then Exit Sub
'If A1 has the time and A2 has the trade:
Application.OnTime Now() + TimeValue("00:00:05"), "Test"
If Range("A1:C1").Value > (Now() - TimeValue("00:00:10")) Then
AppActivate ("Microsoft Excel non-commercial use - alert")
'change the path between the quotes to the path of the wav file to play