Import multiple page web chacune dans une nouvelle feuille

Résolu
Bonjour le forum,

Quelqu'un aurait la solution pour importer le contenu de plusieurs urls de ma feuille et que pour chaque Url, Excel crée une nouvelle feuille dédiée ?
Actuellement mon code me permet de charger toutes les données à la suite les unes des autres juste en dessous de mes urls.
Sub test1()

Sheets("Urls").Select
ActiveCell.Select

Dim I As Long, A As String
' declaring variables
With ActiveSheet
I = 2
Do
A = .Cells(I, 1).Value
If A <> "" Then
lrc = .Cells(Rows.Count, "A").End(xlUp).Row 'last row in C column
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & A, Destination:=Cells(lrc + 1, "A"))
.Name = I
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertEntireRows
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
'.WebTables = "1,2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End If
I = I + 1
Loop Until A = ""
End With


1 réponse

  1. Contributeur
    bonjour, suggestion:
    Sub test1()
    Dim nouvsh As Worksheet
    
    Sheets("Urls").Select
        ActiveCell.Select
      
    Dim I As Long, A As String
    ' declaring variables
    With ActiveSheet
        I = 2
        Do
            A = .Cells(I, 1).Value
            If A <> "" Then
                Set nouvsh = Worksheets.Add(, Worksheets(Worksheets.Count))
                nouvsh.Name = "URL" & CStr(I)
                'lrc = .Cells(Rows.Count, "A").End(xlUp).Row 'last row in C column
                With ActiveSheet.QueryTables.Add(Connection:= _
                    "URL;" & A, Destination:=nouvsh.[A1])
                    .Name = I
                    .FieldNames = True
                    .RowNumbers = False
                    .FillAdjacentFormulas = False
                    .PreserveFormatting = True
                    .RefreshOnFileOpen = False
                    .BackgroundQuery = True
                    .RefreshStyle = xlInsertEntireRows
                    .SavePassword = False
                    .SaveData = True
                    .AdjustColumnWidth = True
                    .RefreshPeriod = 0
                    .WebSelectionType = xlAllTables
                    .WebFormatting = xlWebFormattingNone
                    '.WebTables = "1,2"
                    .WebPreFormattedTextToColumns = True
                    .WebConsecutiveDelimitersAsOne = True
                    .WebSingleBlockTextImport = False
                    .WebDisableDateRecognition = False
                    .WebDisableRedirections = False
                    .Refresh BackgroundQuery:=False
                End With
            End If
            I = I + 1
        Loop Until A = ""
    End With
    End Sub
    0
    1. Ca Marche nickel !!!

      Merci
      0