salut,

Je travaille pour un besoin ponctuelle sur une macro sous excel.
J'ai donc un tableau avec des en têtes séparés par plusieurs lignes et plusieurs colonnes.
J'ai commencé à faire une boucle pour déterminer les cellules aux intersections de mes en têtes de lignes et de colonnes (cellules non vides).

Mais la boucle ne fonctionne pas...

merci d'avance pour un petit coup de pouce.

julien

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
Private Sub CommandButton1_Click()
QICalc.Hide
 
Dim max_line As Integer
Dim max_col As Integer
Dim num_samp As Integer
Dim num_loci As Integer
Dim num_rep As Integer
Dim line As Integer
Dim col As Integer
line = 3
col = 2
 
max_line = TextBox1
max_col = TextBox2
num_samp = TextBox3
num_loci = TextBox4
num_rep = TextBox5
 
Do While line < max_line
    If Not IsEmpty(Cells(line, 1)) Then
        Do While col < max_col
            If Not IsEmpty(Cells(2, col)) Then
            Cells(line, col).Select
            With Selection.Interior
                .ColorIndex = 3
                .Pattern = xlSolid
            Cells(line, col).Formula = line
            End With
            End If
            col = col + 1
        Loop
    End If
line = line + 1
MsgBox ("line " & line) 'test
Loop
 
 
End Sub