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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| Private Sub fnyahooHistQuery(Nom As String, Fund As Worksheet)
Dim Wbk As Workbook
Dim Sh As Worksheet
Dim Rg1 As Range, Rg2 As Range
Dim L As Long, i As Long
Dim C As Integer, j As Long
Dim x As Boolean
Set Wbk = Workbooks.Open(Nom)
Set Sh = Wbk.Worksheets("table")
With Sh
L = .Cells(.Rows.Count, 1).End(xlUp).Row
C = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set Rg1 = .Cells(1, 1).Resize(L, C)
End With
Set Sh = Nothing
Rg1.Copy Fund.Cells(1, 1)
' partir d'ici, c'est quoi l'intérêt?
Set Rg2 = ThisWorkbook.Worksheets(2).Cells(1, 1).Resize(L, C)
For i = 1 To L
For j = 1 To C
If Rg1(i, j).Value = Rg2(i, j).Value Then
x = True
Else
x = False
Exit For
End If
Next j
If Not x Then Exit For
Next i
Set Rg1 = Nothing
Set Rg2 = Nothing
Wbk.Close False
Set Wbk = Nothing
If x = True Then
MsgBox "True"
Else
MsgBox "False"
End If
End Sub
Sub Download()
Dim Sh As Worksheet
Dim NbTitres As Integer, i As Integer
Dim Nom As String
Application.ScreenUpdating = False
Nom = "http://ichart.finance.yahoo.com/table.csv?s=%5EIRX&d=3&e=20&f=2011&g=d&a=0&b=4&c=1960&ignore=.csv"
With ThisWorkbook
NbTitres = .Worksheets("Echantillon").Cells(Rows.Count, 2).End(xlUp).Row - 1
.Worksheets.Add Count:=(NbTitres), After:=.Worksheets("echantillon")
For i = 2 To NbTitres
Set Sh = .Worksheets(i)
Call fnyahooHistQuery(Nom, Sh)
Sh.name = .Worksheets("Echantillon").Cells(i, 1).Value
Set Sh = Nothing
Next i
End With
MsgBox "Traitement terminé..."
End Sub |
Partager