insertion tableau

  • Initiateur de la discussion Michoute
  • Date de début
M

Michoute

Guest
Bonjour
Avec le code ci-dessous je copie des lignes de feuilles de mon classeur sur la Feuil1. Ce tableau est créé à partir de la ligne1. Mais je voudrais en fait mettre plusieurs tableaux à la suite.
en fait je veux:
si la case(1,1) est vide alors
code....
sinon
si case(76,1) est vide alors
code...
ainsi de suite

merci de votre aide

Code:
Private Sub CommandButton1_Click()

Dim position1 As Integer, position2 As Integer, position3 As Integer, position4 As Integer
Dim colonne As Integer, ligne As Integer, ligne2 As Integer, colonne2 As Integer
Dim i As Integer, j As Integer, k As Integer, m As Integer

position1 = ListBox1.ListIndex
position2 = ListBox2.ListIndex
position3 = ListBox3.ListIndex

If position1 = -1 Then
    MsgBox ('Vous devez choisir un thème')
End If

If position2 = -1 Then
    MsgBox ('Vous devez chosir un zonage')
End If

If position3 = -1 Then
    MsgBox ('Vous devez choisir un zonage de comparaison')
End If

colonne = 1
For m = 0 To Me.ListBox4.ListCount - 1
    If Me.ListBox4.Selected(m) = True Then
        For k = 0 To 10
            If position1 = k Then
                Worksheets('Feuil1').Cells(1, 1).Value = ListBox1.Value
                Worksheets('Feuil1').Cells(2, colonne) = Worksheets(k + 4).Cells(1, m + 1)
                ligne2 = 3
                For ligne = 2 To 417
                    For j = 0 To 42
                        If position2 = j And Worksheets(k + 4).Cells(ligne, 2) = ListBox2.Value Then
                            Worksheets('Feuil1').Cells(ligne2, 1) = Worksheets(k + 4).Cells(ligne, 4)
                            Worksheets('Feuil1').Cells(ligne2, colonne) = Worksheets(k + 4).Cells(ligne, m + 1)
                            ligne2 = ligne2 + 1
                        End If
                    Next j
                    For i = 0 To 41
                        If position3 = i And Worksheets(k + 4).Cells(ligne, 2) = ListBox3.Value Then
                            Worksheets('Feuil1').Cells(32, 1) = Worksheets(k + 4).Cells(ligne, 4)
                            Worksheets('Feuil1').Cells(32, colonne) = Worksheets(k + 4).Cells(ligne, m + 1)
                        End If
                    Next i
                    If Worksheets(k + 4).Cells(ligne, 2) = 'Département hors Cabri' Then
                        Worksheets('Feuil1').Cells(33, 1) = Worksheets(k + 4).Cells(ligne, 4)
                        Worksheets('Feuil1').Cells(33, colonne) = Worksheets(k + 4).Cells(ligne, m + 1)
                    End If
                    If Worksheets(k + 4).Cells(ligne, 2) = 'Côtes d'Armor' Then
                        Worksheets('Feuil1').Cells(34, 1) = Worksheets(k + 4).Cells(ligne, 4)
                        Worksheets('Feuil1').Cells(34, colonne) = Worksheets(k + 4).Cells(ligne, m + 1)
                   End If
                Next ligne
           End If
        Next k
        colonne = colonne + 1
    End If
Next m
   
Sheets('Feuil1').Activate

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
314 065
Messages
2 105 255
Membres
109 312
dernier inscrit
GG38