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
| Option Explicit
Sub colore_cellule_active()
Dim col As Integer
Randomize
col = Int(50 * Rnd) + 1
ActiveCell.Interior.ColorIndex = col 'la cellule active est remplie avec une couleur
End Sub
Sub exercice1b()
Dim colonne As Integer
Dim ligne As Integer
'Cells.Clear 'effacer le contenu des cellules
Randomize 'activation une cellule au hasard
colonne = Int(10 * Rnd) + 1
ligne = Int(10 * Rnd) + 1
Cells(ligne, colonne).Activate
Application.Wait (Now + TimeValue("00:00:02")) 'attente de 2s
Call colore_cellule_active 'appel de la fonction colore_cellule
End Sub
Sub exercice1c()
Dim x As Integer
Dim fe As Integer
x = Sheets.Count 'compte le nombre de feuilles
Randomize
fe = Int(x * Rnd) + 1
Worksheets(fe).Activate 'activation de la feuille n°X
Call exercice1b
End Sub |
Partager