Création d'une page de suivi

LMARCO

XLDnaute Nouveau
Bonjour,

Mon problème est le suivant:

Je voudrais créer une feuille de "SUIVI" qui récupére des cellules sur tous les onglets dans le même classeur et je n'arrive pas à faire démarrer dans l'onglet "SUIVI" l'écriture à la ligne 4
Quelqu'un pourrais t-il maider, je joint ma macro.
Merci par avance.


Sub SUIVI()

' EFFACER LIGNE 4 A 200
Rows("4:200").Select
Selection.Delete Shift:=xlUp

' Synthese Macro
Dim i As Long, j As Long
Worksheets("suivi").Select
For i = 1 To Worksheets.Count
j = Range("A65536").End(xlUp).Row + 1
With Worksheets(i)
Cells(j, 1).Value = .Range("G7").Value
Cells(j, 2).Value = .Range("G30").Value
Cells(j, 5).Value = .Range("G31").Value
Cells(j, 8).Value = .Range("G32").Value
Cells(j, 11).Value = .Range("G33").Value
Cells(j, 14).Value = .Range("G34").Value
Cells(j, 17).Value = .Range("G35").Value
Cells(j, 20).Value = .Range("G36").Value

End With
Next

End Sub
 

mapomme

XLDnaute Barbatruc
Supporter XLD
Re : Création d'une page de suivi

Bonjour LMARCO,

Un fichier joint à la question aurait été un plus bien sympathique.

A la 1ere lecture du code et en l'absence de fichier, trois remarques sur votre code:

  • Variable j: si jamais une cellule G7 est vide, on peut ecraser et décaler les lignes d'écriture.
  • La boucle inclut la feuille "Suivi".
  • En début de code on supprime les ligne 4 à 200, mais de quelle feuille ?

Un specimen de code (hors effacement):
VB:
' Synthese Macro
Dim i As Long, j As Long
Worksheets("suivi").Select
j = Range("a65536").End(xlUp).Row
For i = 1 To Worksheets.Count
If Worksheets(i).Name <> "Suivi" Then
  With Worksheets(i)
    j = j + 1
    Cells(j, 1).Value = .Range("G7").Value
    Cells(j, 2).Value = .Range("G30").Value
    Cells(j, 5).Value = .Range("G31").Value
    Cells(j, 8).Value = .Range("G32").Value
    Cells(j, 11).Value = .Range("G33").Value
    Cells(j, 14).Value = .Range("G34").Value
    Cells(j, 17).Value = .Range("G35").Value
    Cells(j, 20).Value = .Range("G36").Value
  End With
End If
Next i

nb: pour démarrer à la ligne 4, remplacer j = Range("a65536").End(xlUp).Row par: j=4
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 555
Messages
2 089 547
Membres
104 208
dernier inscrit
laura29180