Bonjour,

J'ai une petite question qui me turlupine...Soyez indulgents, je débute en VBA

A l'exécution du code suivant, une fenêtre s'ouvre me demandant de sélectionner une macro.... Et le code ne s'exécute pas du tout ! j'ignore totalement pourquoi !!

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 
Sub Bouton1_QuandClic(contrainte)
 
Dim minia As Integer
Dim maxia As Integer
Dim minib As Integer
Dim maxib As Integer
Dim a As Integer
Dim b As Integer
 
minia = 6
maxia = 7
minib = 3
maxib = 5
 
Randomize
a = Int((maxia - minia + 1) * Rnd + minia)
b = Int((maxib - minib + 1) * Rnd + minib)
 
 
Cells(3, 1).value = a
Cells(3, 2).value = b
 
If Cells(a, b).value <> "" Then
 
For c = 1 To 2
For d = 3 To 5
 
Call contrainte
 
If contrainte = "OUI" Then
 
Cells(a, b).value = Cells(c, 1).value
 
Next d
Next c
 
end if
end if
 
End Sub
 
Sub contrainte(c, d)
 
If Cells(c, d).value = "OUI" Then
 
contrainte = "OUI"
 
End Sub