Dim R As Range Set R = Sheets("feuil1").Range("A1:C8") ReDim tablo(1 To R.Rows.Count, 1 To R.Columns.Count) itablo = 1 For i = 1 To R.Rows.Count If R.Rows(i).Hidden = False Then For j = 1 To R.Columns.Count tablo(itablo, j) = R.Cells(i, j).Value Next itablo = itablo + 1 End If Next Sheets("feuil2").Range("F11:H18").Value = tablo
Dim R As Range Set R = Sheets("feuil11").Range("A1:C12") titi = R.SpecialCells(xlCellTypeVisible).Count \ R.Columns.Count ReDim tablo(1 To titi, 1 To R.Columns.Count) itablo = 1 For i = 1 To R.Rows.Count If R.Rows(i).Hidden = False Then For j = 1 To R.Columns.Count tablo(itablo, j) = R.Cells(i, j).Value Next itablo = itablo + 1 If itablo > titi Then Exit For End If Next Dim ou1 As Range, ou2 As Range Set ou1 = Sheets("feuil2").Range("F11") '<<<<<<==== c'est là que du dis où ============ Set ou2 = Sheets("feuil2").Cells(ou1.Row + titi - 1, ou1.Column + R.Columns.Count - 1) Sheets("feuil12").Range(ou1.Address(False, False) & ":" & ou2.Address(False, False)).Value = tablo
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSet rng = ActiveSheet.AutoFilter.Range Dim vtab() As String Dim rC, rL As Range Dim nbCol, nbLigne, ic, il As Integer nbLigne = rng.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 2 nbCol = rng.Rows(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1 ReDim vtab(nbLigne, nbCol) il = 0 ic = 0 For Each rL In rng.Offset(1, 0).Resize(rng.Rows.Count - 1).Rows.SpecialCells(xlCellTypeVisible) If ic > 18 Then 'Pour passer d'une ligne à l'autre dans le tableau il = il + 1 ic = 0 End If vtab(il, ic) = rL.Value ic = ic + 1 Next rL
If ic > 18 Then
If ic > nbCol Then
Dim R As Range Set R = Range("A1:C8") For i = 1 To R.Rows.Count For j = 1 To R.Columns.Count MsgBox R.Cells(i, j) Next Next
Dim R As Range Set R = Range("A1:C8") ReDim tablo(1 To R.Rows.Count, 1 To R.Columns.Count) ' on alimente tablo For i = 1 To R.Rows.Count For j = 1 To R.Columns.Count tablo(i, j) = R.Cells(i, j).Value Next Next ' on va se servir d e tablo et voir ... Range("F1:H8").Value = tablo
Private Sub CommandButton1_Click() Dim R As Range, i as integer, j as integer, itablo as integer Set R = Sheets("feuil11").Range("A1:C8") ReDim tablo(1 To R.Rows.Count, 1 To R.Columns.Count) i = 1 itablo = 1 For Each toto In R.Rows If toto(i).Hidden = False Then For j = 1 To R.Columns.Count tablo(itablo, j) = R.Cells(i, j).Value Next itablo = itablo + 1 End If i = i + 1 If i > R.Rows.Count Then Exit For Next Sheets("feuil12").Range("F11:H18").Value = tablo End Sub
Set rng = ActiveSheet.AutoFilter.Range
[...] [note: on a créé une plage filtrée en vba] [...] Dim tabFilter() As String Dim rC, rL As Range Dim nbLigne, nbCol, ic, il As Integer Set rng = ActiveSheet.AutoFilter.Range 'On copie l'ensemble des données filtrées visibles dans un tableau: 'On calcul la taille du range des cellules visibles nbLigne = rng.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 '-1 car on ignorera la ligne d'entête des colonnes nbCol = rng.Rows(1).SpecialCells(xlCellTypeVisible).Count 'On redimensionne le tableau pour être = au nbre de cellules visibles ReDim tabFilter(1 To nbLigne, 1 To nbCol) il = 1 'Pour chaque ligne dans la plage (range) filtrée des données visibles sans la ligne d'entête: For Each rL In rng.Offset(1, 0).Resize(rng.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible).Rows 'Offset pour ignorer la première ligne qui est l'entête des colonnes 'Pour chaque colonne de cette ligne For ic = 1 To nbCol tabFilter(il, ic) = rL.Columns(ic).Value Next ic il = il + 1 Next rL 'on copie pour voir le résultat Worksheets("Temp").Select 'Feuil pour tester la copie Worksheets("Temp").Cells.Clear 'on la vide Worksheets("Temp").Range(Cells(1, 1), Cells(nbLigne, nbCol)) = tabFilter