En fait dans un classeur j'ai plusieurs feuilles( en fonction du
classeur traité).
Ces feuilles ont la même structure: une table dont le nombre de colonne
est de 6 (Colonne A ... à ..... Colonne F) pour chaque feuille avec
les mêmes titres. Mais le nombre de lignes varient en fonction de
chaque feuille.
Je voudrais consolider toutes les feuilles dans une seule nouvelle
feuille par une macro automatique.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
anonymousA
Bonjour,
Imaginons que toutes tes feuilles s'appellent Feuil1,Feuil2,...Feuil6
Sheets.Add Sheets("Feuil1").Range("A1:F1").Copy Range("A1") lignefinnouvfeuill = 2 For I = 1 To 3 With Sheets("Feuil" & I) lignefin = .Cells.Find("*", .Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row If lignefin > 1 Then If lignefinnouvfeuill + lignefin - 1 > 65537 Then MsgBox "l'opération a été arrétée avant la copie de Feuil" & I & " car le nombre de lignes final dépasse la capacité d'une feuille" Exit Sub End If .Range("A2:F" & lignefin).Copy Range("A" & lignefinnouvfeuill) lignefinnouvfeuill = lignefinnouvfeuill + lignefin - 1 End If End With Next
A+
Bonjour,
Imaginons que toutes tes feuilles s'appellent Feuil1,Feuil2,...Feuil6
Sheets.Add
Sheets("Feuil1").Range("A1:F1").Copy Range("A1")
lignefinnouvfeuill = 2
For I = 1 To 3
With Sheets("Feuil" & I)
lignefin = .Cells.Find("*", .Range("A1"), xlFormulas, ,
xlByRows, xlPrevious).Row
If lignefin > 1 Then
If lignefinnouvfeuill + lignefin - 1 > 65537 Then
MsgBox "l'opération a été arrétée avant la copie
de Feuil" & I & " car le nombre de lignes final dépasse la capacité
d'une feuille"
Exit Sub
End If
.Range("A2:F" & lignefin).Copy Range("A" &
lignefinnouvfeuill)
lignefinnouvfeuill = lignefinnouvfeuill + lignefin - 1
End If
End With
Next
Imaginons que toutes tes feuilles s'appellent Feuil1,Feuil2,...Feuil6
Sheets.Add Sheets("Feuil1").Range("A1:F1").Copy Range("A1") lignefinnouvfeuill = 2 For I = 1 To 3 With Sheets("Feuil" & I) lignefin = .Cells.Find("*", .Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row If lignefin > 1 Then If lignefinnouvfeuill + lignefin - 1 > 65537 Then MsgBox "l'opération a été arrétée avant la copie de Feuil" & I & " car le nombre de lignes final dépasse la capacité d'une feuille" Exit Sub End If .Range("A2:F" & lignefin).Copy Range("A" & lignefinnouvfeuill) lignefinnouvfeuill = lignefinnouvfeuill + lignefin - 1 End If End With Next