Bonjour, j'ai encore besoin de votre aide.

J'ai un UserForm qui contient un tableau (différentes TextBox alignées)
Dans mon exemple j'ai 4 lignes et 3 colonnes, la première ligne servant d'entetes

Les différentes TextBox se nomment:
tb_p_0_z_1 , tb_p_0_z_2 , tb_p_0_z_3
tb_p_1_z_1 , tb_p_1_z_2 , tb_p_1_z_3
tb_p_2_z_1 , tb_p_2_z_2 , tb_p_2_z_3
tb_p_3_z_1 , tb_p_3_z_2 , tb_p_3_z_3

L'objectif est, au survol d'une TextBox, changer la couleur de fond de la TextBox correspondant à son entete.
Dans mon exemple j'y parviens avec le code suivant:
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
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_1.BackColor = RGB(255, 255, 255)
    tb_p_0_z_2.BackColor = RGB(255, 255, 255)
    tb_p_0_z_3.BackColor = RGB(255, 255, 255)
End Sub
 
Private Sub tb_p_1_z_1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_1.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_1_z_2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_2.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_1_z_3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_3.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_2_z_1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_1.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_2_z_2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_2.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_2_z_3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_3.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_3_z_1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_1.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_3_z_2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_2.BackColor = RGB(225, 225, 225)
End Sub
Private Sub tb_p_3_z_3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    tb_p_0_z_3.BackColor = RGB(225, 225, 225)
End Sub
Le problème, c'est que le nombre de colonnes est continuellement amené à grandir, j'en ai plus de 20 à présent, pour une dizaine de lignes... Je cherche à automatiser ces déclarations, mais je ne comprends pas comment faire... Quelqu'un aurait une piste s'il vous plait?