XL 2013 [B]Declanchement du son si la valeur cherchée existe[/B]

ramzi_007

XLDnaute Nouveau
Bonjour,

Je suis nouveau ici, et j'aurais besoin de votre aide pour mon projet :p

Je souhaite créer un fichier excel qui déclenche un son lorsque certains valeurs sont tapées,

par exemple créer plusieurs feuilles excel, sur chaque feuille on a une catégorie d'articles ( catégorie 1, catégorie 2 ... )
sur la feuille principale, on tape des numéros d'articles, le fichier doit automatiquement déclencher un son qui indique dans quelle catégorie cet article se trouve.

j'ai effectué plusieurs recherches, j'ai trouver ces codes la, mais malheureusement je sais pas comment les personnaliser.

Code:
opy the code below to a VBA module in your workbook.

'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\sound.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function

NOTE: The Alarm function expects a WAV file (named sound.wav) in the same path as the workbook. You will need to change this statement to match the name (and path) of your actual sound file. If the sound file is not found, the default system sound will be used.
 

Lone-wolf

XLDnaute Barbatruc
Re : Declanchement du son si la valeur cherchée existe

Bonsoir ramzi et bienvenue sur XLD :)

Si tu as 1000 articles tu imagine un peu l'horchestre avec mille son .wav ?! :confused:
As-tu regarder qu'est-ce qu'il fallait mettre pour Cell et Condition?

A+ :cool:
 
Dernière édition:

ramzi_007

XLDnaute Nouveau
Re : Declanchement du son si la valeur cherchée existe

Re bonjour :)

je recopie toute la page

The Alarm function

Copy the code below to a VBA module in your workbook.

'Windows API function declaration
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Function Alarm(Cell, Condition)
Dim WAVFile As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
On Error GoTo ErrHandler
If Evaluate(Cell.Value & Condition) Then
WAVFile = ThisWorkbook.Path & "\sound.wav" 'Edit this statement
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
Alarm = True
Exit Function
End If
ErrHandler:
Alarm = False
End Function

NOTE: The Alarm function expects a WAV file (named sound.wav) in the same path as the workbook. You will need to change this statement to match the name (and path) of your actual sound file. If the sound file is not found, the default system sound will be used.
Using the Alarm function in a formula

The Alarm function monitors a cell for a specified condition. If the condition is met, the sound file is played and the function returns TRUE. If the condition is not met, the sound file is not played and the function returns FALSE. The Alarm function takes two arguments:

Cell: A reference to a single cell (the cell that you are monitoring). Normally, this will be a cell that contains a formula (but that is not required).
Condition: A text string that describes the condition

Following are examples of formulas that use this function:

=Alarm(A1,">=1000")

The sound will play when the value in cell A1 is greater than or equal to 1,000.

=Alarm(C12,"<0")

The sound will play when the value in cell C12 is negative.
Tips

The function is evaluated whenever any cell that depends on the reference cell is changed. The sound can get annoying!
Normally, you will want to use this function in only one cell. If you use it in more than one cell, you will not be able to tell which instance of the function triggered the sound.
 

Lone-wolf

XLDnaute Barbatruc
Re : Declanchement du son si la valeur cherchée existe

Re ramzi,

comme je te l'ai dit, regarde La PJ. Mais il faut que tu poste le classeur, sinon dur dur.


A+ :cool:
 

Pièces jointes

  • Nouveau dossier.zip
    931.7 KB · Affichages: 38
  • Nouveau dossier.zip
    931.7 KB · Affichages: 33

ramzi_007

XLDnaute Nouveau
Re : Declanchement du son si la valeur cherchée existe

WOOOW

Merci merci merci :eek: :eek: :eek:

tout est nickel je dois chercher juste comment déclencher le son une fois le bouton entrer est appuyé, parce-que la douchette scanne le code et passe automatiquement a la cellule en dessous.

Mister Lone-wolf, t'es vraiment magnifique, je commencerai a apprendre le VBA pour aider les autres personnes en besoin, comme tu as fais pour moi.
 

ramzi_007

XLDnaute Nouveau
Re : Declanchement du son si la valeur cherchée existe

Big Boss,

Je suis coincé encore une fois :(, j'arrive pas a introduire la commande " ONKEY " dans le code qu tu as créé,
je sais même pas s'il s'agit de la bonne commande,
j'ai besoin que le résultat s'affiche une fois la touche entrer est cliqué", car comme j'ai déjà expliqué, la douchette lit le code et clique automatiquement sur entrer.
 

Lone-wolf

XLDnaute Barbatruc
Re : Declanchement du son si la valeur cherchée existe

Bonsoir ramzi,

de quel résultat parle-tu? Sinon regarde le fichier je viens de faires une modification.


A+ :cool:
 

Pièces jointes

  • Lone-wolf.xlsm
    28.4 KB · Affichages: 42
  • Lone-wolf.xlsm
    28.4 KB · Affichages: 48
Dernière édition:

ramzi_007

XLDnaute Nouveau
Re : Declanchement du son si la valeur cherchée existe

Bonsoir Lone,

Ca marche pas le fichier, il m'affiche pas les villes.

Pour expliquer encore mieux, après avoir collé ou scanné le tracking ( par exemple cellule A2), on doit cliquer sur entrer pour que le nom de la ville s'affiche sur B2 et le curseur passé directement a A3.
 

Statistiques des forums

Discussions
312 305
Messages
2 087 087
Membres
103 461
dernier inscrit
dams94