Currently I am running the following codes on two seperate worksheets, but would like to run both on the same wrksheet. How do you combine the two subs into one?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lRow As Long, WF As WorksheetFunction
Set WF = Application.WorksheetFunction
If Not Application.Intersect(Target, Range("D
")) Is Nothing Then
With Sheet2
lRow = .[A1].CurrentRegion.Rows.Count + 1
.Cells(lRow, 1) = Now
.Cells(lRow, 2) = WF.Subtotal(9, Sheet1.Range("D
"))
.Cells(lRow, 3) = WF.Subtotal(9, Sheet1.Range("D
")) / Sheets("Notionals").Range("B16").Value
End With
End If
Set WF = Nothing
End Sub
Private Sub Worksheet_Change1(ByVal Target As Range)
Dim lRow As Long, WF As WorksheetFunction
Set WF = Application.WorksheetFunction
If Not Application.Intersect(Target, Range("D
")) Is Nothing Then
With Sheet4
lRow = .[A1].CurrentRegion.Rows.Count + 1
.Cells(lRow, 1) = Now
.Cells(lRow, 2) = WF.SumIf(Sheet1.Range("AF:AF"), "*US*", Sheet1.Range("D
"))
.Cells(lRow, 3) = WF.SumIf(Sheet1.Range("AF:AF"), "*US*", Sheet1.Range("D
")) / Sheets("Notionals").Range("K16").Value
End With
End If
Set WF = Nothing
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lRow As Long, WF As WorksheetFunction
Set WF = Application.WorksheetFunction
If Not Application.Intersect(Target, Range("D
With Sheet2
lRow = .[A1].CurrentRegion.Rows.Count + 1
.Cells(lRow, 1) = Now
.Cells(lRow, 2) = WF.Subtotal(9, Sheet1.Range("D
.Cells(lRow, 3) = WF.Subtotal(9, Sheet1.Range("D
End With
End If
Set WF = Nothing
End Sub
Private Sub Worksheet_Change1(ByVal Target As Range)
Dim lRow As Long, WF As WorksheetFunction
Set WF = Application.WorksheetFunction
If Not Application.Intersect(Target, Range("D
With Sheet4
lRow = .[A1].CurrentRegion.Rows.Count + 1
.Cells(lRow, 1) = Now
.Cells(lRow, 2) = WF.SumIf(Sheet1.Range("AF:AF"), "*US*", Sheet1.Range("D
.Cells(lRow, 3) = WF.SumIf(Sheet1.Range("AF:AF"), "*US*", Sheet1.Range("D
End With
End If
Set WF = Nothing
End Sub