XL 2010 application.sum

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

yahya belbachir

XLDnaute Occasionnel
Bonjour
pour faire un calcul dans une feuil en vba,j'ai crée un code sur (worksheetfunction),le code suivant:
******************************
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lg As Long
lg = Cells(Rows.Count, "C").End(xlUp).Row
If Not Intersect(Target, Range("F2:F" & lg)) Is Nothing Then
Cells(lg, 6) = Cells(lg, 3) + Cells(lg, 4)
Range("A:G" & Target.Row).Borders.Weight = xlThin
End If
End Sub
****************************
mais ne fonctionne pas,pour être plus clair mon fichier çi joint.
merci
 

Pièces jointes

Dernière édition:
bonjour
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Range("A" & Target.Row) <> "" Then
        With Range("A1:G" & Target.Row)
           .Borders(xlDiagonalDown).LineStyle = xlNone
           .Borders(xlDiagonalUp).LineStyle = xlNone
           .Borders(xlEdgeLeft).LineStyle = xlContinuous
           .Borders(xlEdgeTop).LineStyle = xlContinuous
           .Borders(xlEdgeBottom).LineStyle = xlContinuous
           .Borders(xlEdgeRight).LineStyle = xlContinuous
           .Borders(xlInsideVertical).LineStyle = xlContinuous
           .Borders(xlInsideHorizontal).LineStyle = xlContinuous
        End With
    End If
    Application.EnableEvents = False
        Range("F" & Target.Row) = Range("C" & Target.Row) + Range("D" & Target.Row) - Range("E" & Target.Row)
    Application.EnableEvents = True
End Sub
 
bonjour
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Range("A" & Target.Row) <> "" Then
        With Range("A1:G" & Target.Row)
           .Borders(xlDiagonalDown).LineStyle = xlNone
           .Borders(xlDiagonalUp).LineStyle = xlNone
           .Borders(xlEdgeLeft).LineStyle = xlContinuous
           .Borders(xlEdgeTop).LineStyle = xlContinuous
           .Borders(xlEdgeBottom).LineStyle = xlContinuous
           .Borders(xlEdgeRight).LineStyle = xlContinuous
           .Borders(xlInsideVertical).LineStyle = xlContinuous
           .Borders(xlInsideHorizontal).LineStyle = xlContinuous
        End With
    End If
    Application.EnableEvents = False
        Range("F" & Target.Row) = Range("C" & Target.Row) + Range("D" & Target.Row) - Range("E" & Target.Row)
    Application.EnableEvents = True
End Sub
Bonjour JM27,

Je me permets d'apporter ma modeste contribution à ton code
VB:
With Range("A1:G" & Target.Row)
    .Borders.Weight = xlThin
End With
 
bonjour
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Range("A" & Target.Row) <> "" Then
        With Range("A1:G" & Target.Row)
           .Borders(xlDiagonalDown).LineStyle = xlNone
           .Borders(xlDiagonalUp).LineStyle = xlNone
           .Borders(xlEdgeLeft).LineStyle = xlContinuous
           .Borders(xlEdgeTop).LineStyle = xlContinuous
           .Borders(xlEdgeBottom).LineStyle = xlContinuous
           .Borders(xlEdgeRight).LineStyle = xlContinuous
           .Borders(xlInsideVertical).LineStyle = xlContinuous
           .Borders(xlInsideHorizontal).LineStyle = xlContinuous
        End With
    End If
    Application.EnableEvents = False
        Range("F" & Target.Row) = Range("C" & Target.Row) + Range("D" & Target.Row) - Range("E" & Target.Row)
    Application.EnableEvents = True
End Sub
merci infiniment
j'ai bien résolu mon probléme grâce à ton code
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
9
Affichages
404
Réponses
14
Affichages
332
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
1 K
Réponses
5
Affichages
707
  • Question Question
Microsoft 365 Probléme VBA
Réponses
8
Affichages
447
Réponses
4
Affichages
407
Retour