Macro pour supp une ligne vide

nonossov Messages postés 638 Statut Membre -  
nonossov Messages postés 638 Statut Membre -
Bonjour,

j'ai une feuil qui contient la premiere ligne vide et je vouderai la supp avec un code macro automatique, merci de m'aider!!

2 réponses

  1. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 831
     
    Bonjour,

    Tu peux utiliser l'enregistreur de macro pour t'aider à le coder toi même...

    - Tu lances l'enregistreur,

    - Tu supprimes la ligne à la main

    - Tu arrête l'enregistreur puis tu regardes le code que ça t'a généré.

    - Il ne te reste plus qu'à l'adapter à tes besoins.
    0
    1. nonossov Messages postés 638 Statut Membre
       
      comment puis je ajouter cette macro a une autre macro??
      0
    2. jordane45 Messages postés 30427 Date d'inscription   Statut Modérateur Dernière intervention   4 831
       
      Tu fais un call
      0
    3. nonossov Messages postés 638 Statut Membre
       
      comment je comment par
      Sub
      ...
      ...
      ...
      ...
      call
      ...
      ...
      ...
      End sub

      ?? comme ça
      0
    4. nonossov Messages postés 638 Statut Membre
       
      Voila le code que j'ai pu sortir avec:

      Sub supp()
      Call NETTOYAGE(18254, 654897)
      Rows("1:1").Select
      Selection.Delete Shift:=xlUp
      End Sub

      est ce qu'il est correct?

      la macro entiere:

      Sub NETTOYAGE()
      If MsgBox("Etes-vous sur de vouloir nettoyer le journal?", vbOKCancel) = vbCancel Then
          End
      End If
         
      
       Dim sh As Worksheet
      Dim ws As Worksheet
      Dim a As Long
      Dim b As Long
      
      Set ws = Sheets("Input")
      Set sh = Sheets("Output")
      
      b = ws.Range("A1").End(xlDown).Row
      c = sh.Range("A1").End(xlDown).Row
      sh.Activate
      sh.Range("A1", Cells(c, "K")).Clear
      'sh.Range("A1", Cells(c, "K")).Interior.Color = RGB(255, 255, 255)
      For a = 2 To b
      sh.Cells(a, "C") = ws.Cells(a, "C")
      sh.Cells(a, "A") = ws.Cells(a, "G")
      sh.Cells(a, "E") = ws.Cells(a, "K")
      sh.Cells(a, "B") = ws.Cells(a, "L")
      sh.Cells(a, "G") = ws.Cells(a, "M")
      sh.Cells(a, "D") = ws.Cells(a, "X")
      
      
      Next
      sh.Range("A2", Cells(b, "A")).NumberFormat = "dd/mm/yyyy;@"
      
      Dim maplageC As Range
      
      Set maplageC = sh.Range("G2", Cells(b, "G"))
      
      For Each cellule In maplageC
        If cellule.Value > 0 Then
           sh.Cells(cellule.Row, 6).Value = "C"
        Else
          sh.Cells(cellule.Row, 6).Value = "D"
          
          End If
      
      Next
      
      
      Range("H2").Select
      ActiveCell.FormulaR1C1 = "=MID(RC[-4],SEARCH("".TIF"",RC[-4])-8,8)"
      Selection.Copy
      Range("G60000").End(xlUp).Offset(0, 1).Select
      Range(Selection, Selection.End(xlUp)).Select
      ActiveSheet.Paste
      Selection.Copy
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
              :=False, Transpose:=False
      Range("D2").Select
      ActiveCell.FormulaR1C1 = "=RC[4]"
      Selection.Copy
      Range(Selection, Selection.End(xlDown)).Select
      ActiveSheet.Paste
      Selection.Copy
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
              :=False, Transpose:=False
      Columns("H:H").ClearContents
      Columns("D:D").EntireColumn.AutoFit
      Range("A2").Select
      
      
      Columns("A:G").Select
      Selection.AutoFilter
      ActiveSheet.Range("$A:$G").AutoFilter Field:=7, Criteria1:=">0", Operator:=xlAnd
      Range("G60000").End(xlUp).Offset(0, 1).Select
      ActiveCell.FormulaR1C1 = "=RC[-1]"
      Selection.Copy
      Range(Selection, Range("H2")).Select
      ActiveSheet.Paste
      Selection.AutoFilter
      
      Columns("H:H").Copy
      Range("H1").Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
              :=False, Transpose:=False
      
      ActiveSheet.Range("$A:$H").AutoFilter Field:=7, Criteria1:=">0", Operator:=xlAnd
              
      Columns("G:G").SpecialCells(xlCellTypeVisible).ClearContents
      Selection.AutoFilter
      Columns("F:F").Delete Shift:=xlToLeft
      
      
      End Sub
      
      Sub supp()
          Call NETTOYAGE(18254, 654897)
          Rows("1:1").Select
          Selection.Delete Shift:=xlUp
      End Sub
      
          
          
          
          
      Sub test()
      
      Columns("A:G").Select
      Selection.AutoFilter
      ActiveSheet.Range("$A:$G").AutoFilter Field:=7, Criteria1:=">0", Operator:=xlAnd
      Range("G60000").End(xlUp).Offset(0, 1).Select
      ActiveCell.FormulaR1C1 = "=RC[-1]"
      Selection.Copy
      Range(Selection, Range("H2")).Select
      ActiveSheet.Paste
      Selection.AutoFilter
      
      Columns("H:H").Copy
      Range("H1").Select
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
              :=False, Transpose:=False
      
      ActiveSheet.Range("$A:$H").AutoFilter Field:=7, Criteria1:=">0", Operator:=xlAnd
              
      Columns("G:G").SpecialCells(xlCellTypeVisible).ClearContents
      Selection.AutoFilter
      
      
      
      End Sub
      0
  2. yg_be Messages postés 23437 Date d'inscription   Statut Contributeur Dernière intervention   Ambassadeur 1 588
     
    Sub supp()
        Call NETTOYAGE()
        Sheets("Output").Rows("1:1").Delete Shift:=xlUp
    End Sub 
    0
    1. nonossov Messages postés 638 Statut Membre
       
      elle n'a pas supprimé la ligne
      0
    2. nonossov Messages postés 638 Statut Membre
       
      qlq'un peut m'aider? merci
      0