toufous
Messages postés16Date d'inscriptionmardi 18 octobre 2005StatutMembreDernière intervention 3 mars 2010
-
23 févr. 2010 à 09:13
toufous
Messages postés16Date d'inscriptionmardi 18 octobre 2005StatutMembreDernière intervention 3 mars 2010
-
3 mars 2010 à 21:31
Bonjour à tous!
Bon voila suite à mon autre post, j'ai créer ce code:
Private Sub CommandButton1_Click()
Dim CelD As Range
Dim CelF As Range
Dim CelC As Range
Set CelD = Cells.Find(Date, LookIn:=xlValues, lookat:=xlWhole)
Set CelF = CelD.Offset(ColumnOffset:=12)
Set CelC = CelD.Offset(RowsOffset:=1)
If Range(CelC).Value <> "" Then
Range(CelD, CelF).Select
Selection.Copy
CelD.Offset(RowOffset:=1).Activate
Selection.Insert
Range(CelD.Offset(RowOffset:=1), CelF.Offset(RowOffset:=1)).Select
Selection.ClearContents
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
End With
MsgBox ("Mise à Jour : OK !")
Else
MsgBox ("Pas besoin !")
End If
End Sub
ucfoutu
Messages postés18038Date d'inscriptionlundi 7 décembre 2009StatutModérateurDernière intervention11 avril 2018219 23 févr. 2010 à 09:43
Bonjour,
- nous n'avons pas à chercher "ton autre post" pour savoir de quoi il s'agit ! Tu dois l'exposer clairement dans CETTE discussion (ou alors il fallait continuer l'autre).
- la moindre des choses est de signaler la ligne en erreur.
____________________
Vous aimez Codes-Sources ? Il vous aide ? Cliquez ici pour l'aider à continuer Cliquer sur "Réponse acceptée" en bas d'une solution adéquate est
bigfish_le vrai
Messages postés1835Date d'inscriptionvendredi 13 mai 2005StatutMembreDernière intervention20 novembre 201314 23 févr. 2010 à 14:14
Salut,
Complètement d'accord avec la remarque de Renfield !
Et d'ailleurs il y en aura d'autre des erreurs !
Note que les méthodes Select et Activate ainsi que la propriété Selection sont à proscrire autan que possible. Cela ralenti le code, et à tendance à rendre un aveugle épileptique...
donc :
Private Sub CommandButton1_Click()
Dim CelD As Range
Dim CelF As Range
Dim CelC As Range
Set CelD = Cells.Find(Date, LookIn:=xlValues, lookat:=xlWhole)
'si find à échoué!
If CelD Is Nothing Then Exit Sub
Set CelF = CelD.Offset(0, 12)
Set CelC = CelD.Offset(1, 0)
If Not CelC.Value <> "" Then ' <-- celc est deja un objet range !!!
Range(CelD, CelF).Copy
CelD.Offset(1,0).Insert
With Range(CelD.Offset(1,0), CelF.Offset(1,0))
.ClearContents
With .Borders '(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
With .Borders(xlEdgeLeft)
.Weight = xlThin
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
MsgBox ("Mise à Jour : OK !")
Else
MsgBox ("Pas besoin !")
End If
End Sub