en savoir plus sur les zones de liste

M

mielpops

Guest
salut bébère !salut le forum
J'ai avancé dans mon code. J'ai trouvé ceci :
Dim m as single
With Worksheets('certificat')
If Listbox1.listindex<0 then exit sub
m=listbox1.listindex +33
end with
cells(m,1)=''
cells(m,2)=''
cells(m,3)=''

Rows('m:m').delete shift :=xl up

Mais il y a toujours un bug. Je ne comprends pas. Voilà, si quelqu'un, peut m'aider...
Bonne soirée à vous tous merci d'avance à ceux qui me répondront.
 
B

bebere

Guest
bonsoir Mielpops

Sub test()
Dim test As Boolean
With Worksheets('certificat') 'Important ne pas oublier les points
'pas de sélection
'If listbox1.ListIndex = -1 Then Exit Sub
m =listbox1.Value
'la ligne suivante peut remplacer If listbox1.ListIndex = -1 Then Exit Sub
'If m = '' Then Exit Sub
test = False
For Each cel In .Range('A1:A9') 'à adapter
'si tu n'as rien à droite,ligne suivante
'If cel = m Then .Cells(cel.Row, 1).EntireRow.Delete
'sinon,ligne suivante
If cel = m Then
test = True
.Range('A' & cel.Row & ':D' & cel.Row).Delete Shift:=xlShiftUp 'à adapter
End If
If test = True Then Exit For
Next cel

End With

End Sub
à bientôt
 

Discussions similaires

Statistiques des forums

Discussions
312 330
Messages
2 087 347
Membres
103 526
dernier inscrit
HEC