Private Sub CommandButton2_Click()
'
UserForm1.Hide
Sheets("CR12 Input").Cells.Copy Sheets("Futures Output").Range("A1")
Sheets("CR12 Input").Cells.Copy Sheets("Bloomberg Output").Range("A1")
Application.CutCopyMode = False
Sheets("TIPS").Rows("38:38").ClearContents
Sheets("TIPS").Rows("31:31").EntireRow.Hidden = False
Sheets("Bounce Off").Range("C1508").ClearContents
Sheets("Bounce Off").Rows("1000:1000").EntireRow.Hidden = False
'The Zoom Function is an exception that the Sheet MUST be Selected.
Sheets("Bloomberg Output").Select
ActiveWindow.Zoom = 55
Sheets("Futures Output").Select
ActiveWindow.Zoom = 70
Sheets("CR12 Input").Select
ActiveWindow.Zoom = 60
Sheets("TIPS").Select
Range("A31").Activate
ActiveWindow.Zoom = 80
Sheets("SWAP Checker").Select
ActiveWindow.Zoom = 65
Sheets("Bounce Off").Select
ActiveWindow.Zoom = 80
Sheets("CR12 Input").Columns("K:K").TextToColumns Destination:=Sheets("CR12 Input").Range("K1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Sheets("SWAP Checker").Cells.Copy
Sheets("SWAP Checker").Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With Sheets("SWAP Checker")
.Columns("K:AA").Delete Shift:=xlToLeft
.Range("K5").FormulaR1C1 = "CR12 Value"
.Range("L5").FormulaR1C1 = "Total"
.Range("M5").FormulaR1C1 = "Difference"
.Range("K5:M5").Font.Bold = True
.Range("K8").FormulaR1C1 = _
"=IF(RC[-9]="""","""",VLOOKUP(RC[-9],'CR12 Input'!R2C11:R1120C32,22,FALSE))"
.Range("K8").Copy .Range("K9:K1089")
.Columns("K:K").Copy
.Columns("K:K").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Range("L8").FormulaR1C1 = "=IF(R[-1]C[-1]="""",RC[-1]+R[1]C[-1],"""")"
.Range("L8").Copy .Range("L9:L1046")
Application.CutCopyMode = False
.Columns("L:L").Copy
.Columns("L:L").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Columns("L:L").Replace What:="#VALUE!", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.Columns("L:L").Replace What:="0", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False
.Range("M8").FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-3]-RC[-1])"
.Range("M8").Copy .Range("M9:M1089")
Application.CutCopyMode = False
With .Columns("M:M").Interior
.ColorIndex = 36
.Pattern = xlSolid
.Font.Bold = True
End With
.Columns("K:M").EntireColumn.AutoFit
.Columns("L:L").EntireColumn.AutoFit
.Columns("M:M").EntireColumn.AutoFit
.Columns("M:M").Copy
.Columns("M:M").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("M:M").NumberFormat = "#,##0.00"
End With
With Sheets("Futures Output")
.Columns("A:X").Delete Shift:=xlToLeft
.Columns("A:X").EntireColumn.AutoFit
.Columns("C:C").Delete Shift:=xlToLeft
.Columns("D:D").Delete Shift:=xlToLeft
.Columns("E:E").ClearContents
.Range("D1").ClearContents
.Columns("D:D").TextToColumns Destination:=.Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
.Columns("D:D").Delete Shift:=xlToLeft
.Range("D1").FormulaR1C1 = "Mkt Price(Rep Ccy)"
.Columns("D:D").EntireColumn.AutoFit
.Columns("F:H").Delete Shift:=xlToLeft
.Columns("G:AH").Delete Shift:=xlToLeft
.Range("G1").FormulaR1C1 = "Contract Size"
.Columns("G:G").EntireColumn.AutoFit
.Range("G2").FormulaR1C1 = _
"=VLOOKUP(RC[-5],'Data, do not amend'!R1C4:R3000C5,2,FALSE)"
.Range("G2").Copy .Range("G3:G5430")
Application.CutCopyMode = False
.Columns("G:G").Copy
.Columns("G:G").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Columns("G:G").Replace What:="#N/A", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False
.Range("H1").ActiveCell.FormulaR1C1 = "Value"
.Range("I1").FormulaR1C1 = "Difference"
.Range("H2").FormulaR1C1 = "=IF(RC[-7]="""","""",RC[-5]*RC[-4]*RC[-1]/RC[-2])"
.Range("I2").FormulaR1C1 = "=IF(RC[-8]="""","""",RC[-1]-RC[-4])"
.Range("H2:I2").Copy .Range("H3:H5880")
.Columns("E:E").NumberFormat = "#,##0.00"
.Columns("H:H").NumberFormat = "#,##0.00"
.Columns("I:I").NumberFormat = "#,##0.00"
.Range("H2:I2").Copy .Range("H3:H5880")
.Columns("H:I").Copy
.Columns("H:I").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("J:W").Delete Shift:=xlToLeft
.Range("A1").AutoFilter
.Range("A1").AutoFilter Field:=1, Criteria1:="FINANCIAL FUTURES"
.Columns("H:I").EntireColumn.AutoFit
End With
With Sheets("Bloomberg Output")
.Columns("F:F").Cut
.Columns("A:A").Insert Shift:=xlToRight
.Columns("K:K").Cut
.Columns("B:B").Insert Shift:=xlToRight
.Columns("AZ:AZ").Cut
.Columns("C:C").Insert Shift:=xlToRight
.Columns("D:D").Insert Shift:=xlToRight
.Columns("AB:AB").Cut
.Columns("E:E").Insert Shift:=xlToRight
.Columns("C:C").EntireColumn.AutoFit
.Columns("A:A").EntireColumn.AutoFit
.Columns("E:E").EntireColumn.AutoFit
.Columns("AD:AD").Cut
.Columns("F:F").Insert Shift:=xlToRight
.Columns("AG:AG").Cut
.Columns("G:G").Insert Shift:=xlToRight
.Columns("H:H").Insert Shift:=xlToRight
.Columns("G:G").EntireColumn.AutoFit
.Columns("AN:AN").Cut
.Columns("I:I").Insert Shift:=xlToRight
.Columns("J:J").Insert Shift:=xlToRight
.Columns("J:J").Insert Shift:=xlToRight
.Columns("J:J").Insert Shift:=xlToRight
.Columns("J:J").Insert Shift:=xlToRight
.Columns("J:J").Insert Shift:=xlToRight
.Columns("O:DJ").Delete Shift:=xlToLeft
.Columns("D:D").Insert Shift:=xlToRight
.Range("D2").FormulaR1C1 = "Corp Isin"
.Range("E2").FormulaR1C1 = "=CONCATENATE(RC[-2],"" "",RC[-1])"
.Columns("E:E").EntireColumn.AutoFit
.Range("E2").AutoFill Destination:=.Range("E2:E1500"), Type:=xlFillDefault
.Range("D2").AutoFill Destination:=.Range("D2:D1500"), Type:=xlFillDefault
.Range("E2:E1500").Copy
.Range("C2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("D:E").Delete Shift:=xlToLeft
.Columns("C:C").EntireColumn.AutoFit
.Columns("H:H").Insert Shift:=xlToRight
.Range("G2").FormulaR1C1 = _
"=IF(LEN(RC[-1])=17,MID(RC[-1],6,3),IF(LEN(RC[-1])=16,MID(RC[-1],6,2),IF(LEN(RC[-1])=15,MID(RC[-1],6,1))))"
.Range("G2").AutoFill Destination:=.Range("G2:G1500"), Type:=xlFillDefault
.Range("H2").FormulaR1C1 = "=IF(RC[1]<1,RC[-1]-RC[-1]-RC[-1],RC[-1])"
.Range("H2").AutoFill Destination:=.Range("H2:H1500"), Type:=xlFillDefault
.Columns("H:H").NumberFormat = "0"
With .Columns("H:H")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
.Range("H2:H1500").Copy
.Range("F2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With .Columns("F:F")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
.Columns("G:H").Delete Shift:=xlToLeft
.Columns("E:E").EntireColumn.AutoFit
.Columns("E:E").NumberFormat = "#,##0"
.Columns("G:G").EntireColumn.AutoFit
.Range("G1").FormulaR1C1 = "CR12e GAI"
.Range("F1").FormulaR1C1 = "CR12e Days"
.Columns("G:G").ColumnWidth = 17.86
.Range("H2").FormulaR1C1 = "=ROUND(RC[-1],0)"
.Columns("H:H").NumberFormat = "#,##0"
.Range("H2").AutoFill Destination:=.Range("H2:H1500"), Type:=xlFillDefault
.Range("H2:H1500").Copy
.Range("G2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("H:H").Delete Shift:=xlToLeft
.Columns("G:G").NumberFormat = "#,##0"
With .Range("F1:G1")
Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleSingle
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
.Range("H1").FormulaR1C1 = "Bloomberg Days"
.Range("I1").FormulaR1C1 = "Bloomberg Accrued"
With .Range("H1:I1")
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With
Columns("H:I").EntireColumn.AutoFit
With Range("H1:I1500")
.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
.Range("J1").FormulaR1C1 = "Day Difference"
.Range("K1").FormulaR1C1 = "Value Difference"
With .Range("J1:K1")
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With
.Columns("J:K").EntireColumn.AutoFit
.Range("J2").FormulaR1C1 = "=if"
.Range("J2").FormulaR1C1 = "=RC[-4]-RC[-2]"
.Range("K2").FormulaR1C1 = "=RC[-4]-RC[-2]"
.Range("J2:K2").AutoFill Destination:=Range("J2:K1500"), Type:=xlFillDefault
.Range("L1").FormulaR1C1 = "Days Check"
.Range("M1").FormulaR1C1 = "3% Value Check"
With .Range("L1:M1")
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With
.Columns("L:M").EntireColumn.AutoFit
.Range("L2").FormulaR1C1 = "=IF(RC[-2]=0,""OK"",""CHECK"")"
.Range("M2").FormulaR1C1 = "=IF((SQRT(POWER(RC[-2],2))/(RC[-6]+0.000000001))<0.03,""OK"",""CHECK"")"
.Range("L2:M2").Copy .Range("L3:L1500")
.Range("N1").FormulaR1C1 = "Overall"
.Range("N2").FormulaR1C1 = "=CONCATENATE(RC[-2]&RC[-1])"
.Range("O1").FormulaR1C1 = "Overall Check"
.Range("O2").FormulaR1C1 = "=IF(RC[-1]=""OKOK"",""OK"",""CHECK"")"
.Range("N2:O2").Copy .Range("N3:N1500")
'Not Sure What Cell You Want "Day Check" In here...
'ActiveCell.FormulaR1C1 = "Day Check"
.Range("K1").FormulaR1C1 = "Accrued Check"
With .Range("J1:K1")
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With
.Columns("J:K").EntireColumn.AutoFit
.Range("J2").FormulaR1C1 = "=RC[-4]-RC[-2]"
.Range("K2").FormulaR1C1 = "=IF(RC[-4]=RC[-2],""ok"",""CHECK THIS ONE !"")"
.Range("J2:K2").AutoFill Destination:=.Range("J2:K1500"), Type:=xlFillDefault
With .Range("H2:H1500")
.NumberFormat = "0"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
.Range("I2:I1500").NumberFormat = "#,##0"
.Columns("K:K").ColumnWidth = 18.14
With .Columns("J:J")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
.Columns("A:A").ColumnWidth = 10.86
.Columns("B:B").ColumnWidth = 9.29
.Columns("C:C").ColumnWidth = 23
.Columns("D:D").ColumnWidth = 54.43
End With
Sheets("Bounce Off").Range("A5:B1500").ClearContents
With Sheets("Bloomberg Output")
.Cells.Replace What:=" Corp Isin", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.Range("C2:C1500").Copy
Sheets("Bounce Off").Range("A5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Range("E2:E800").Copy
Sheets("Bounce Off").Range("B5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End With
With Sheets("TIPS")
.Range("B8").FormulaR1C1 = "=VLOOKUP(RC[-1],'CR12 Input'!R2C11:R1000C28,18,FALSE)"
.Range("B8").Copy .Range("B10:B11")
.Range("B8").Copy .Range("B13:B16")
Application.CutCopyMode = False
.Range("D8").FormulaR1C1 = "=VLOOKUP(RC[-3],'CR12 Input'!R1C11:R1000C30,20,FALSE)"
.Range("D8").Copy .Range("D10:D11")
.Range("D8").Copy .Range("D13:D16")
Application.CutCopyMode = False
.Columns("D:D").Copy
.Columns("D:D").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("E:E").Insert Shift:=xlToRight
.Columns("D:D").TextToColumns Destination:=.Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("D:D").TextToColumns Destination:=.Range("D1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
.Range("E8:E16").Copy
.Range("D8").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Columns("E:E").Delete Shift:=xlToLeft
.Range("F8").FormulaR1C1 = _
"=VLOOKUP(RC[-5],'CR12 Input'!R2C11:R1000C36,26,FALSE)"
.Range("F8").Copy .Range("F10:F11")
.Range("F8").Copy .Range("F13:F16")
Application.CutCopyMode = False
.Columns("G:G").Insert Shift:=xlToRight
.Columns("G:G").Delete Shift:=xlToLeft
.Range("G8").FormulaR1C1 = _
"=IF('CR12 Input'!R2C3=""C"",""0"",VLOOKUP(TIPS!RC[-6],'CR12 Input'!R1C11:R1135C37,27,FALSE))"
.Range("G8").Copy .Range("G10:G11")
.Range("G8").Copy .Range("G13:G16")
.Columns("A:G").Copy
.Columns("A:G").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
.Range("H8").Copy
.Range("H8").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Range("H8").Replace What:="#N/A", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False
.Range("H8").FormulaR1C1 = "=((RC[-4]*RC[-6]*RC[-3])/(RC[-2]*100))+RC[-1]"
.Range("H8").Copy .Range("H10:H11")
.Range("H8").Copy .Range("H13:H16")
Application.CutCopyMode = False
.Range("I8").FormulaR1C1 = _
"=VLOOKUP(RC[-8],'CR12 Input'!R2C11:R1136C32,22,FALSE)"
.Range("I8").Copy .Range("I10:I11")
.Range("I8").Copy .Range("I13:I16")
Application.CutCopyMode = False
.Range("J8").FormulaR1C1 = "=RC[-1]-RC[-2]"
.Range("J8").Copy .Range("J10:J11")
.Range("J8").Copy .Range("J13:J16")
.Cells.Copy
.Cells.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Cells.Replace What:="#N/A", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
.Cells.Replace What:="#DIV/0!", Replacement:="", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Application.CutCopyMode = False
.Range("B37").ClearContents
End With
Sheets("Futures Output").Columns("B:B").ColumnWidth = 48.43
Sheets("Bloomberg Output").Columns("B:B").EntireColumn.Hidden = True
Sheets("SWAP Checker").Select
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 50
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("Futures Output").Select
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 65
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("TIPS").Select
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.Zoom = 70
.PrintErrors = xlPrintErrorsDisplayed
End With
Sheets("Bounce Off").Select
c = Range("B2").Value
Range("A1").Select
MsgBox "The date is currently set to " & c & ". If this is incorrect please amend. Save the file in your test environment and re-open it on the Bloomberg machine. Remember to use Ctrl+y before leaving the BB terminal!"
End Sub