XL 2010 application.sum

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

  • TEST.xlsm
    18.1 KB · Affichages: 6
Dernière édition:

JM27

XLDnaute Barbatruc
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
 

cp4

XLDnaute Barbatruc
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
 

yahya belbachir

XLDnaute Occasionnel
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
 

Discussions similaires

Réponses
4
Affichages
738

Statistiques des forums

Discussions
311 716
Messages
2 081 848
Membres
101 826
dernier inscrit
dododu89