Combiné deux worksheet_change
n
Bonjour , je veux Combiné ce deux worksheet_change
Macro 1
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim lRow As Long
lRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
For i = 5 To lRow
If Not Intersect(Target, Range("j" & i)) Is Nothing Then
Range("w" & i).Value = Range("j" & i).Value
End If
Next
End SubMacro 2
Option Explicit
Sub MepFormule(ByVal Sh As Worksheet)
Dim DerniereLigne As Long
Dim AireZ As Range
With Sh
If .Cells(.Rows.Count, "X").End(xlUp).Row > .Cells(.Rows.Count, "Y").End(xlUp).Row Then
DerniereLigne = .Cells(.Rows.Count, "X").End(xlUp).Row
Else
DerniereLigne = .Cells(.Rows.Count, "Y").End(xlUp).Row
End If
Set AireZ = .Range(.Cells(5, "Z"), .Cells(DerniereLigne, "Z"))
AireZ.FormulaR1C1 = "=IF(RC[-2]="""","""",RC[-2]-RC[-1])"
End With
Set AireZ = Nothing
End SubMerci
Invité
Bonjour Nizar2015
Quand vous souhaitez mettre des codes sur le forum, merci d'utiliser les balises grâce au bouton </>
A+
n
OK ... pardon
Bonjour , je veux Combiné ce deux worksheet_change
Macro 1
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim lRow As Long
lRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
For i = 5 To lRow
If Not Intersect(Target, Range("j" & i)) Is Nothing Then
Range("w" & i).Value = Range("j" & i).Value
End If
Next
End SubMacro 2
Option Explicit
Sub MepFormule(ByVal Sh As Worksheet)
Dim DerniereLigne As Long
Dim AireZ As Range
With Sh
If .Cells(.Rows.Count, "X").End(xlUp).Row > .Cells(.Rows.Count, "Y").End(xlUp).Row Then
DerniereLigne = .Cells(.Rows.Count, "X").End(xlUp).Row
Else
DerniereLigne = .Cells(.Rows.Count, "Y").End(xlUp).Row
End If
Set AireZ = .Range(.Cells(5, "Z"), .Cells(DerniereLigne, "Z"))
AireZ.FormulaR1C1 = "=IF(RC[-2]="""","""",RC[-2]-RC[-1])"
End With
Set AireZ = Nothing
End SubMERCI