Wednesday, August 20, 2008

VBA-Netting

Sub netting()
'
' Macro netting
'
'
'------------------------------------------------------------------------------------------
'Prepairing the tabs to receive the data. The older data from the tabs will be cleared out.
'------------------------------------------------------------------------------------------
Sheets("Full").Select 'Clearing the Contents of Full tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Validation").Select 'Clearing the Validation Tab
Range("A2:Q2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.ClearContents
Sheets("Long").Select 'Clearing the contents of Long tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Short").Select 'Clearing the contents of Short tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Short_Re").Select 'Clearing the contents of Short_Re tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Long_Re").Select 'Clearing the contents of Long_Re tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Result").Select 'Clearing the contents of Result tab
Cells.Select
Selection.ClearContents
Selection.ClearContents 'Cleared
Sheets("Input").Select 'Copying Header from the Input Tab
Rows("1:1").Select
Selection.Copy
Sheets("Result").Select
Range("A1").Select
ActiveSheet.Paste 'Pasted the header in the Result Tab
Selection.Font.Bold = True
Range("Y1").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents 'Clearing the end part of header after column Y
Range("A1").Select
Sheets("Input").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1:X1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Full").Select
Range("A1").Select
ActiveSheet.Paste ' Copying all the data to Full tab. We will use this tab and not the Input tab now
'------------------------------------------------------------------------------------------------
'The data from the Full tab will be moved to Short and Long tab based on the LONG/SHORT Column
'------------------------------------------------------------------------------------------------
Sheets("Full").Select
Selection.AutoFilter Field:=21, Criteria1:="Short" 'Selecting the short trades
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Short").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Full").Select
Selection.AutoFilter Field:=21, Criteria1:="Long" 'Selecting the long trades
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Long").Select
Range("A1").Select
ActiveSheet.Paste
'------------------------------------------------------------------------------------------
'Calculating the coupon in column L from the PAYFORMULA in Long Tab
'------------------------------------------------------------------------------------------
Columns("L:L").Select
Selection.Insert shift:=xlToRight
Range("L1").Select
ActiveCell.FormulaR1C1 = "Coupon"
Range("L2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[6],SEARCH(""%"",RC[6])-1)"
Range("A1").Select
lastRow = Selection.End(xlDown).Row
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L" & lastRow)
Range("L2:L" & lastRow).Select
'------------------------------------------------------------------------------------------
'Calculating Residual Maturity=Maturity-today in Column AC in Long Tab
'------------------------------------------------------------------------------------------
Range("AC1").Select
ActiveCell.FormulaR1C1 = "Residual Maturity"
Range("AD1").Select
ActiveCell.FormulaR1C1 = "Maturity"
Range("AD2").Select
ActiveCell.FormulaR1C1 = _
"=DATE(LEFT(RC[-10],4),MID(RC[-10],5,2),RIGHT(RC[-10],2))"
Range("AC2").Select
ActiveCell.FormulaR1C1 = "=RC[1]-TODAY()"
Range("AC2").Select
Selection.NumberFormat = "General"
Range("AC2:AD2").Select
Selection.AutoFill Destination:=Range("AC2:AD" & lastRow)
ActiveSheet.Calculate
Range("AC2:AD" & lastRow).Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Short").Select
'------------------------------------------------------------------------------------------
'Calculating the coupon in column L from the RECFORMULA in Short Tab
'------------------------------------------------------------------------------------------
Columns("L:L").Select
Selection.Insert shift:=xlToRight
Range("L1").Select
ActiveCell.FormulaR1C1 = "Coupon"
Range("L2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],SEARCH(""%"",RC[-1])-1)"
Range("A1").Select
lastRow = Selection.End(xlDown).Row
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L" & lastRow)
Range("L2:L" & lastRow).Select
'------------------------------------------------------------------------------------------
'Calculating Residual Maturity=Maturity-today in Column AC in Short Tab
'------------------------------------------------------------------------------------------
Range("AC1").Select
ActiveCell.FormulaR1C1 = "Residual Maturity"
Range("AD1").Select
ActiveCell.FormulaR1C1 = "Maturity"
Range("AD2").Select
ActiveCell.FormulaR1C1 = _
"=DATE(LEFT(RC[-10],4),MID(RC[-10],5,2),RIGHT(RC[-10],2))"
Range("AC2").Select
ActiveCell.FormulaR1C1 = "=RC[1]-TODAY()"
Range("AC2").Select
Selection.NumberFormat = "General"
Range("AC2:AD2").Select
Selection.AutoFill Destination:=Range("AC2:AD" & lastRow)
ActiveSheet.Calculate
Range("AC2:AD" & lastRow).Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("L14").Select
Range("A1").Select
Range("A2:AD2").Select
'Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
'--------------------------------------------------------------------------------------------------------
'Sorting the data in the Short tab. The sort order is by PAYNotional,ResidualMaturity and then by Coupon
'--------------------------------------------------------------------------------------------------------
Selection.Sort Key1:=Range("U2"), Order1:=xlAscending, Key2:=Range _
("AC2"), Order2:=xlAscending, Key3:=Range("L2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal
Sheets("Long").Select
Range("O10").Select
Range("A2:AD2").Select
'Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlDown)).Select
'--------------------------------------------------------------------------------------------------------
'Sorting the data in the Long tab. The sort order is by PAYNotional,ResidualMaturity and then by Coupon
'--------------------------------------------------------------------------------------------------------
Selection.Sort Key1:=Range("U2"), Order1:=xlAscending, Key2:=Range _
("AC2"), Order2:=xlAscending, Key3:=Range("L2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortTextAsNumbers _
, DataOption3:=xlSortNormal
'-------------------------------------------------------------------------------------------------------------
'The netting process starts here.
'The Long and Short tab gets netted for exact maturity and rest trades are marked as Not Netted.
'These not netted trades will be netted off once again in the LOng_Re and Short_Re tabs using the maturity band
'-------------------------------------------------------------------------------------------------------------
Application.ScreenUpdating = False
Dim longCoupon, shortCoupon, longNotional, shortNotional, longMaturity, shortMaturity, longPV01, shortPV01 As Double
Dim shortResidualMaturity, longResidualMaturity As Double
Dim bigL, smallL, notnettedPoint, bigloopCount, smallloopCount, finalFlag, sm_i As Integer
Dim vali_Row_Ct As Integer
finalFlag = 0
Sheets("Short").Select
Range("A1").Select
shortRows = ActiveCell.End(xlDown).Row
Sheets("Long").Select
Range("A1").Select
longrows = ActiveCell.End(xlDown).Row
bigloopCount = longrows
smallloopCount = shortRows
notnettedPoint = 2
Sheets(1).Select
vali_Row_Ct = 2
For bigL = 2 To bigloopCount
For smallL = notnettedPoint To smallloopCount
If (bigL = bigloopCount And finalFlag = 1) Then
For sm_i = smallL To smallloopCount
Sheets("Short").Activate
Range("Z" & sm_i).Value = "N"
Next sm_i
Exit For
End If
Sheets("Long").Activate
longCoupon = Range("L" & bigL).Value + 0
longNotional = Range("U" & bigL).Value
longMaturity = Range("J" & bigL).Value
longResidualMaturity = Range("AC" & bigL).Value
Sheets("Short").Activate
shortCoupon = Range("L" & smallL).Value + 0
shortNotional = Range("U" & smallL).Value
shortMaturity = Range("J" & smallL).Value
shortResidualMaturity = Range("AC" & smallL).Value
If (longNotional = shortNotional) Then
If (longResidualMaturity = shortResidualMaturity) Then
If ((longCoupon - shortCoupon) > 0.15) Then
Sheets("Short").Activate
Range("z" & smallL).Value = "N"
notnettedPoint = smallL + 1
ElseIf ((shortCoupon - longCoupon) > 0.15) Then
Sheets("Long").Activate
Range("z" & bigL).Value = "N"
If (bigL = bigloopCount) Then
Sheets("Short").Activate
Range("z" & smallL).Value = "N"
Else
Exit For
End If
Else
Sheets("Long").Activate
longPV01 = Range("Y" & bigL).Value
Sheets("Short").Activate
shortPV01 = Range("Y" & smallL).Value
If ((longPV01 - shortPV01) > 0) Then
Sheets("Long").Select
Range("z" & bigL).Value = "Y"
Range("AA" & bigL).Value = Sheets("Short").Range("B" & smallL).Value
'--------------------------For Validation --------------------------------------
Sheets("Validation").Range("A" & vali_Row_Ct).Value = Sheets("Long").Range("B" & bigL).Value
Sheets("Validation").Range("B" & vali_Row_Ct).Value = Sheets("Short").Range("B" & smallL).Value
Sheets("Validation").Range("I" & vali_Row_Ct).Value = Sheets("Long").Range("L" & bigL).Value
Sheets("Validation").Range("J" & vali_Row_Ct).Value = Sheets("Short").Range("L" & smallL).Value
Sheets("Validation").Range("M" & vali_Row_Ct).Value = Sheets("Long").Range("AC" & bigL).Value
Sheets("Validation").Range("N" & vali_Row_Ct).Value = Sheets("Short").Range("AC" & smallL).Value
vali_Row_Ct = vali_Row_Ct + 1
'-------------------------------------------------------------------------------
If (bigL = bigloopCount) Then
finalFlag = 1
Else
Exit For
End If
Else
Sheets("Short").Select
Range("z" & smallL).Value = "Y"
Range("AA" & smallL).Value = Sheets("Long").Range("B" & bigL).Value
notnettedPoint = smallL + 1
'--------------------------For Validation --------------------------------------
Sheets("Validation").Range("A" & vali_Row_Ct).Value = Sheets("Short").Range("B" & smallL).Value
Sheets("Validation").Range("B" & vali_Row_Ct).Value = Sheets("Long").Range("B" & bigL).Value
Sheets("Validation").Range("I" & vali_Row_Ct).Value = Sheets("Short").Range("L" & smallL).Value
Sheets("Validation").Range("J" & vali_Row_Ct).Value = Sheets("Long").Range("L" & bigL).Value
Sheets("Validation").Range("M" & vali_Row_Ct).Value = Sheets("Short").Range("AC" & smallL).Value
Sheets("Validation").Range("N" & vali_Row_Ct).Value = Sheets("Long").Range("AC" & bigL).Value
vali_Row_Ct = vali_Row_Ct + 1
'-------------------------------------------------------------------------------
If (bigL = bigloopCount) Then
finalFlag = 1
Else
Exit For
End If
End If
End If
Else
If ((longResidualMaturity - shortResidualMaturity) > 0) Then
Sheets("Short").Activate
Range("z" & smallL).Value = "N"
notnettedPoint = smallL + 1
Else
Sheets("Long").Activate
Range("z" & bigL).Value = "N"
If (bigL = bigloopCount) Then
Sheets("Short").Activate
Range("z" & smallL).Value = "N"
Else
Exit For
End If
End If
End If
Else
If ((longNotional - shortNotional) > 0) Then
Sheets("Short").Range("Z" & smallL).Value = "N"
notnettedPoint = smallL + 1
Else
Sheets("Long").Range("Z" & bigL).Value = "N"
If (bigL = bigloopCount) Then
Sheets("Short").Activate
Range("z" & smallL).Value = "N"
Else
Exit For
End If
End If
End If
Next smallL
Next bigL
'----------------------------------------------------------------------------
' we need to do the netting of band of maturity after the full netting is over.
'
'------------------------------------------------------------------------------
Sheets("Long").Select
Range("A1:AD1").Select
Selection.AutoFilter
Range("K1").Select
Selection.End(xlToRight).Select
Range("Z1").Select
Selection.AutoFilter Field:=26, Criteria1:="N"
Cells.Select
Range("S1").Activate
Selection.Copy
Sheets("Long_Re").Select
Cells.Select
Application.CutCopyMode = False
Selection.ClearContents
'-------------------------------------------------------------------------------
' Copying not netted trades from Long tab to Long_Re tab
'-------------------------------------------------------------------------------
Sheets("Long").Select
Selection.Copy
Sheets("Long_Re").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Short").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1:AD1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=26, Criteria1:="N"
Cells.Select
Selection.Copy
'-------------------------------------------------------------------------------
'Copying not netted trades from Short tab to Short_Re tab
'-------------------------------------------------------------------------------
Sheets("Short_Re").Select
Cells.Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("Short").Select
Selection.Copy
Sheets("Short_Re").Select
Range("A1").Select
ActiveSheet.Paste
'--------------------------------------------------------------------------------
Sheets("Short_Re").Select
Range("A1").Select
shortRows = ActiveCell.End(xlDown).Row
Sheets("Long_Re").Select
Range("A1").Select
longrows = ActiveCell.End(xlDown).Row
bigloopCount = longrows
smallloopCount = shortRows
notnettedPoint = 2
For bigL = 2 To bigloopCount
For smallL = notnettedPoint To smallloopCount
Sheets("Long_Re").Activate
longCoupon = Range("L" & bigL).Value + 0
longNotional = Range("U" & bigL).Value
longMaturity = Range("J" & bigL).Value
longNettedFlag = Range("Z" & bigL).Value
longResidualMaturity = Range("AC" & bigL).Value
Sheets("Short_Re").Activate
shortCoupon = Range("L" & smallL).Value + 0
shortNotional = Range("U" & smallL).Value
shortMaturity = Range("J" & smallL).Value
shortNettedFlag = Range("Z" & smallL).Value
shortResidualMaturity = Range("AC" & smallL).Value
If (longNettedFlag = "Y") Then
Exit For
End If
If (longNettedFlag = "N") Then
If (shortNettedFlag = "N") Then
If (longNotional = shortNotional) Then
If ((longCoupon - shortCoupon) > 0.15) Then
Sheets("Short_Re").Activate
'Range("z" & smallL).Value = "N"
'notnettedPoint = smallL + 1
ElseIf ((shortCoupon - longCoupon) > 0.15) Then
Sheets("Long_Re").Activate
Range("z" & bigL).Value = "N"
'Exit For
Else
Sheets("Long_Re").Activate
longPV01 = Range("Y" & bigL).Value
Sheets("Short_Re").Activate
shortPV01 = Range("Y" & smallL).Value
Range("AT" & smallL).Value = "Diff is less than 0.15"
If (longResidualMaturity < 30) Then
Exit For
ElseIf (shortResidualMaturity < 30) Then
'notnettedPoint = smallL + 1
ElseIf ((longResidualMaturity < 365 And shortResidualMaturity < 365 _
And (((longResidualMaturity - shortResidualMaturity) <> 0) _
Or ((shortResidualMaturity - longResidualMaturity) <> 0))) _
_
Or (longResidualMaturity > 365 And shortResidualMaturity > 365 _
And (((longResidualMaturity - shortResidualMaturity) <> 0) _
Or ((shortResidualMaturity - longResidualMaturity) <> 0)))) Then
If ((longPV01 - shortPV01) > 0) Then
Sheets("Long_Re").Select
Range("z" & bigL).Value = "Y"
Range("AA" & bigL).Value = Sheets("Short_Re").Range("B" & smallL).Value
Sheets("Short_Re").Select
Range("z" & smallL).Value = ""
'notnettedPoint = smallL + 1
'--------------------------For Validation --------------------------------------
Sheets("Validation").Range("A" & vali_Row_Ct).Value = Sheets("Long_Re").Range("B" & bigL).Value
Sheets("Validation").Range("B" & vali_Row_Ct).Value = Sheets("Short_Re").Range("B" & smallL).Value
Sheets("Validation").Range("I" & vali_Row_Ct).Value = Sheets("Long_Re").Range("L" & bigL).Value
Sheets("Validation").Range("J" & vali_Row_Ct).Value = Sheets("Short_Re").Range("L" & smallL).Value
Sheets("Validation").Range("M" & vali_Row_Ct).Value = Sheets("Long_Re").Range("AC" & bigL).Value
Sheets("Validation").Range("N" & vali_Row_Ct).Value = Sheets("Short_Re").Range("AC" & smallL).Value
vali_Row_Ct = vali_Row_Ct + 1
'-------------------------------------------------------------------------------
Exit For
Else
Sheets("Short_Re").Select
Range("z" & smallL).Value = "Y"
Range("AA" & smallL).Value = Sheets("Long_Re").Range("B" & bigL).Value
Sheets("Long_Re").Select
Range("z" & bigL).Value = ""
'notnettedPoint = smallL + 1
'--------------------------For Validation --------------------------------------
Sheets("Validation").Range("A" & vali_Row_Ct).Value = Sheets("Short_Re").Range("B" & smallL).Value
Sheets("Validation").Range("B" & vali_Row_Ct).Value = Sheets("Long_Re").Range("B" & bigL).Value
Sheets("Validation").Range("I" & vali_Row_Ct).Value = Sheets("Short_Re").Range("L" & smallL).Value
Sheets("Validation").Range("J" & vali_Row_Ct).Value = Sheets("Long_Re").Range("L" & bigL).Value
Sheets("Validation").Range("M" & vali_Row_Ct).Value = Sheets("Short_Re").Range("AC" & smallL).Value
Sheets("Validation").Range("N" & vali_Row_Ct).Value = Sheets("Long_Re").Range("AC" & bigL).Value
vali_Row_Ct = vali_Row_Ct + 1
'-------------------------------------------------------------------------------
Exit For
End If
End If
End If
Else
If ((longNotional - shortNotional) > 0) Then
'Sheets("Short_Re").Range("Z" & smallL).Value = "N"
'notnettedPoint = smallL + 1
Else
'Sheets("Long_Re").Range("Z" & bigL).Value = "N"
Exit For
End If
End If
Else
'notnettedPoint = smallL + 1
End If
End If
Next
Next
'--------------------------------------------------------------------------------------
' Data needs to be moved from the Long and Short tabs to the Result tab
'--------------------------------------------------------------------------------------
Sheets("Long_Re").Select
Range("A1:AA1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=26, Criteria1:="N"
'Range(Selection, Selection.End(xlToRight)).Select
Range("A1:AA1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Result").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Rows("2:2").Select
Selection.Delete shift:=xlUp
Sheets("Short_Re").Select
Range("A1:AA1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=26, Criteria1:="N"
'Range(Selection, Selection.End(xlToRight)).Select
Range("A1:AA1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Result").Select
Range("A65536").Select
Selection.End(xlUp).Select
Selection.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("Z2").Select
row_delete = Selection.End(xlDown).Row + 1
If (row_delete >= 65536) Then
row_delete = 2
End If
Cells(row_delete, 1).Select
Range(Selection, "AB" & row_delete).Select
Application.CutCopyMode = False
Selection.Cut
Rows("1:1").Select
ActiveSheet.Paste
Cells(row_delete, 1).Select
Range(Selection, "AB" & row_delete).Select
Selection.Delete shift:=xlUp
Rows("1:1").Select
Selection.Font.Bold = True
Range("A1").Select
'----------------------------------------Validation Sheet Checks ----------------------------
Sheets("Validation").Select
Range("C2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],Input!C2:C24,23,0)"
Range("D2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],Input!C2:C24,23,0)"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]+RC[-1]"
Range("F2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],Input!C2:C10,9,0)"
Range("G2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],Input!C2:C10,9,0)"
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=DATE(LEFT(RC[-2],4),MID(RC[-2],5,2),RIGHT(RC[-2],2))-DATE(LEFT(RC[-1],4),MID(RC[-1],5,2),RIGHT(RC[-1],2))"
Range("H3").Select
Range("C2:H2").Select
If vali_Row_Ct > 3 Then Selection.AutoFill Destination:=Range("C2:H" & vali_Row_Ct - 1)
Range("K2").Select
ActiveCell.FormulaR1C1 = "=IF(ABS(RC[-2]-RC[-1])<0.15,""Ok"",""Check"")"
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-11],Input!C[-10]:C[2],13,0)-VLOOKUP(RC[-10],Input!C[-10]:C[2],13,0)"
Range("K2:L2").Select
If vali_Row_Ct > 3 Then Selection.AutoFill Destination:=Range("K2:L" & vali_Row_Ct - 1)
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]>365,IF(ABS(RC[-1]-RC[-2])<31,""ok"",""check""),if(rc[-1]>30,IF(ABS(RC[-1]-RC[-2])<8,""Ok"",""Check""),IF(RC[-1]=RC[-2],""Ok"",""Check"")))"
Range("O2").Select
If vali_Row_Ct > 3 Then Selection.AutoFill Destination:=Range("O2:O" & vali_Row_Ct - 1)
ActiveSheet.Calculate
Range("A1").Select
'----------------------------------Validation in results sheets ------------------------------
Application.ScreenUpdating = True
Sheets("Result").Select
Range("A1").Select
fin_row = Selection.End(xlDown).Row
Range("Z1").Select
ActiveCell.FormulaR1C1 = "PV01 Orig"
Range("AA1").Select
ActiveCell.FormulaR1C1 = "PV01 Check with Orig"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "Check for inclusion of netted deals"
Range("AC1").Select
ActiveCell.FormulaR1C1 = "Zone Orig"
Range("AD1").Select
ActiveCell.FormulaR1C1 = "Zone Check"
Range("Z2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-24],Input!C[-24]:C[-2],23,0)"
Range("AA2").Select
ActiveCell.FormulaR1C1 = "=RC[-2]-RC[-1]"
Range("AB2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(RC[-26],Validation!C[-27],1,0)),""Ok"",""Check"")"
Range("AB3").Select
Range("AC2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-27],Input!C[-27]:C[-6],22,0)"
Range("AD2").Select
ActiveCell.FormulaR1C1 = "=RC[-6]=RC[-1]"
Range("Z2:AD2").Select
Selection.AutoFill Destination:=Range("Z2:AD" & fin_row)
ActiveSheet.Calculate
Range("A1").Select
End Sub

No comments: