Afficher un message
Vieux 17/05/2008, 12h02   #9 (permalink)
skoobi
XLDnaute Barbatruc
 
Avatar de skoobi
 
Date d'inscription: juin 2007
Localisation: Riedisheim (Mulhouse)
Version Excel : Excel 2003 (PC)
Messages: 2 572
Par défaut Re : Effacer les données d'une ligne et retrier les données de la feuille

Re,

ça devrait aller mieux comme ça:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Lig, derlig, num1 As Integer, Couleur As Long
Lig = Target.Row
If Target.Count > 1 And Target.Value = "" Then Exit Sub
If Target.Column = 26 Then
  With Sheets("Données")
    .Visible = True
    derlig = .Range("A65500").End(xlUp).Row + 1
    .Cells(derlig, 2).Value = Cells(Lig, 2).Value
    .Cells(derlig, 3).Value = Cells(Lig, 3).Value
    .Cells(derlig, 4).Value = Cells(Lig, 10).Value
    .Cells(derlig, 5).Value = Cells(Lig, 9).Value
    .Cells(derlig, 6).Value = Cells(Lig, 12).Value
    .Cells(derlig, 7).Value = Cells(Lig, 11).Value
    .Cells(derlig, 8).Value = Cells(Lig, 20).Value
    .Cells(derlig, 9).Value = Cells(Lig, 26).Value
    .Cells(derlig, 10).Value = Cells(Lig, 8).Value
    .Cells(derlig, 11).Value = Cells(Lig, 21).Value
    .Cells(derlig, 12).Value = Cells(Lig, 22).Value
    .Cells(derlig, 13).Value = Cells(Lig, 23).Value
    .Cells(derlig, 14).Value = Cells(Lig, 24).Value
    .Cells(derlig, 15).Value = Cells(Lig, 25).Value
    .Cells(derlig, 1).Value = ActiveSheet.Name
    num1 = .Cells(derlig - 1, 16).Value
    .Cells(derlig, 16).Value = num1 + 1
  End With
  derlig = [A4].End(xlDown).Row
  Range("A" & Target.Row & ":Z" & Target.Row).SpecialCells(xlCellTypeConstants).ClearContents
  Range("A4", Cells(derlig, Target.Column)).Sort Key1:=Range("B4"), Order1:=xlAscending, Key2:=Range( _
      "C4"), Order2:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:= _
      False, Orientation:=xlTopToBottom
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
__________________
@+
skoobi

On en apprend tous les jours

Filtrer un tableau, c'est par ici:
http://www.excel-downloads.com/forum...tml#post548211

Trier un tableau, c'est par là:
http://www.excel-downloads.com/forum...tml#post558394

Aidez ce forum, devenez supporter:
http://www.excel-downloads.com/forum...tml#post442476
skoobi est déconnecté   Réponse avec citation