1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Sub Recap_vols()
Dim Dat1 As Date, Dat2 As Date
Dim x As Byte, i As Integer, j As Integer, r As Integer
Dim Sh1 As Worksheet, Sh2 As Worksheet
Set Sh1 = Sheets("Vol 30d 3 mois")
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Test " & Sheets.Count
Set Sh2 = ActiveSheet
With Sh2.Cells(1, 1)
.Value = "Dates"
.ColumnWidth = 25
.HorizontalAlignment = xlRight
.Font.Bold = True
End With
Sh2.Cells(2, 1) = "Vols"
Sh2.Cells(2, 1).Font.Bold = True
Dat1 = Sh1.Cells(2, 2)
Dat2 = Sh1.Cells(2, 255).End(xlToLeft)
For x = 0 To (Dat2 - Dat1)
Sh2.Cells(1, x + 2) = Dat1 + x
Next x
r = 3
For i = 1 To Sh1.Cells(65535, 1).End(xlUp).Row
If Sh1.Cells(i, 1) = "VOLATILITY_30D" Then
Sh2.Cells(r, 1) = Sh1.Cells(i - 1, 1)
For j = 2 To Sh1.Cells(i, 255).End(xlToLeft).Column
Set C = Sh2.Range("A1:IV1").Find(Sh1.Cells(i - 1, j).Value)
If Not C Is Nothing Then
Sh2.Cells(r, C.Column) = Sh1.Cells(i, j)
End If
Next j
r = r + 1
End If
Next i
End Sub |
Partager