Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

supprimer 99 lignes sur 100 toutes les cent lignes

4 réponses
Avatar
ponsgre
sur un fichier excel je dois supprimer 99 lignes sur 100 tous les 100 lignes
et j'aimerai connaitre une méthode rapide autre que de supprimer manuellement
99 lignes

4 réponses

Avatar
dre
Bonjour,

En attendant une solution par macro, une solution simple par formule :
Ne pas effacer les lignes, mais recopier les lignes à conserver sur une
autre feuille :
=INDIRECT("Feuil1!"&CAR(COLONNE()+64)&LIGNE()*100)
à copier vers la droite et vers le bas.
Les lignes 100, 200, 300, ... seront recopiées.
Si ce sont d'autres lignes, il faut ajuster l'argument LIGNE()

dré




sur un fichier excel je dois supprimer 99 lignes sur 100 tous les 100 lignes
et j'aimerai connaitre une méthode rapide autre que de supprimer manuellement
99 lignes


Avatar
dre
Re,

A lire le complément d'explication :
"je garde la ligne 1, 101, 201, 301 etc"
donné sous un autre pseudo ici :
http://www.excel-downloads.com/forum/75151-supprimer-automatiquement-des-lignes.html

la formule que je t'ai proposée deviendrait :
=INDIRECT("Feuil1!"&CAR(COLONNE()+64)&(1+(LIGNE()-1)*100))

dré






Bonjour,

En attendant une solution par macro, une solution simple par formule :
Ne pas effacer les lignes, mais recopier les lignes à conserver sur une
autre feuille :
=INDIRECT("Feuil1!"&CAR(COLONNE()+64)&LIGNE()*100)
à copier vers la droite et vers le bas.
Les lignes 100, 200, 300, ... seront recopiées.
Si ce sont d'autres lignes, il faut ajuster l'argument LIGNE()

dré




sur un fichier excel je dois supprimer 99 lignes sur 100 tous les 100 lignes
et j'aimerai connaitre une méthode rapide autre que de supprimer manuellement
99 lignes




Avatar
FFO
Salut à toi
Je te propose ce code :

Range("A2").Select
n = 0
Repère = ActiveCell.Address
For I = 1 To Range("A65535").End(xlUp).Row
ActiveCell.Offset(1, 0).Select
n = n + 1
If n = 99 Then
Range(ActiveCell, Repère).EntireRow.Select
Selection.Delete
ActiveCell.Offset(1, 0).Select
n = 0
Repère = ActiveCell.Address
End If
Next

La suppression démarre à partir de la cellule A2 pour laisser la première
ligne avec l'entète des colonnes intact

Donc la 1° suppression s'opére de la ligne 2 + 99 lignes jusqu'à la ligne
101 incluse
Devant laisser la 2° ligne (ex ligne 102 qui doit être concervée) la 2°
suppression démarrera de la ligne 3 + 99 lignes jusqu'à la ligne 102 incluse
Ainsi de suite

Ais je bien compris ta demande ???
Dis moi !!!


sur un fichier excel je dois supprimer 99 lignes sur 100 tous les 100 lignes
et j'aimerai connaitre une méthode rapide autre que de supprimer manuellement
99 lignes


Avatar
lSteph
Bonjour,

Voici un joujou qui peut faire cela http://cjoint.com/?feqUqkPO6C

Matériel:
Un userform , 3 textbox avec label Debut Fin, Nombre de lignes par lot
Un label avec spinbutton (ligne à conserver), Deux Commandbuttons

Cordialement.
LSteph

Voici le code du Userform:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
Option Explicit

Private Sub CommandButton1_Click()
Call validControl
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub validControl()
Dim i As Byte
For i = 1 To 3
With Me
If Val(.Controls("TextBox" & i).Text) = 0 Then
.Controls("TextBox" & i).SetFocus
MsgBox "incomplet"
Exit Sub
End If
If Val(TextBox2) < Val(TextBox1) Then
MsgBox "valeurs incompatibles"
TextBox2.SetFocus
Exit Sub
End If
If Val(TextBox3) > (Val(TextBox2) - Val(TextBox1) + 1) Then
MsgBox "nombre de ligne ne peut être supérieur à la plage"
TextBox2.SetFocus
Exit Sub
End If
End With

Next

Call suppress
End Sub



Private Sub SpinButton1_Change()
Label5 = SpinButton1
End Sub

Private Sub TextBox1_AfterUpdate()
Call majcontrols
End Sub

Private Sub TextBox2_AfterUpdate()
Call majcontrols
End Sub
Private Sub TextBox3_AfterUpdate()
Call majcontrols
End Sub

Private Sub UserForm_Initialize()
TextBox1 = 2
TextBox2 = 65536
TextBox3 = 100
With SpinButton1
.Min = Val(TextBox1)
.Max = Val(TextBox1) + Val(TextBox3) - 1
.Value = Val(TextBox1)
End With
Label5 = SpinButton1
End Sub

Private Sub majcontrols()
If Val(TextBox3) > (Val(TextBox2) - Val(TextBox1) + 1) Then
Application.EnableEvents = False
TextBox3 = (Val(TextBox2) - Val(TextBox1) + 1)
Application.EnableEvents = True
End If
With SpinButton1
.Min = Val(TextBox1)
.Max = Val(TextBox1) + Val(TextBox3) - 1
If .Value < .Min Then .Value = .Min
If .Value > .Max Then .Value = .Max
End With
Label5 = SpinButton1
End Sub
Private Sub suppress()
Application.ScreenUpdating = False
ActiveCell.Select
Dim i As Long, last As Long
For i = Val(TextBox2) To Val(TextBox1) Step -1
If (i - Val(Label5)) Mod Val(TextBox3) <> 0 Then
If i <> Val(Label5) Then Rows(i).Delete
Else
last = i: Exit For
End If
Application.StatusBar = _
CInt((Val(TextBox2) - i) / Val(TextBox2) * 100) & _
"% lignes traitées"
Next
Application.StatusBar = "---------"
For i = last To Val(Label5) Step -Val(TextBox3)
If i <> Val(Label5) Then
Range(Cells(i - 1, 1), Cells(i - (Val(TextBox3) - 1),
1)).EntireRow.Delete
Else
If Val(TextBox1) < Val(Label5) Then
Range(Cells(i - 1, 1), Cells(Val(TextBox1), 1)).EntireRow.Delete
End If

End If
Application.StatusBar = _
CInt((Val(TextBox2) - i) / Val(TextBox2) * 100) & _
"% lignes traitées"
Next

Application.StatusBar = False
Unload Me
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''