Récupération multi-page en VBA pour le WEB
Résolu/Fermé
maximedu45
-
20 nov. 2017 à 17:23
gbinforme Messages postés 14946 Date d'inscription lundi 18 octobre 2004 Statut Contributeur Dernière intervention 24 juin 2020 - 21 nov. 2017 à 11:39
gbinforme Messages postés 14946 Date d'inscription lundi 18 octobre 2004 Statut Contributeur Dernière intervention 24 juin 2020 - 21 nov. 2017 à 11:39
A voir également:
- Récupération multi-page en VBA pour le WEB
- Web office - Guide
- Supprimer une page word - Guide
- Traduire une page web - Guide
- Capture page web - Guide
- Mettre google en page d'accueil - Guide
2 réponses
yg_be
Messages postés
23476
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
20 février 2025
Ambassadeur
1 568
20 nov. 2017 à 21:01
20 nov. 2017 à 21:01
bonsoir, tu écris "Le problème c'est qu'il y a des pages qui ne fonctionne pas !!".
Je ne comprends pas le problème, ni le lien avec la valeur de i.
Je ne comprends pas le problème, ni le lien avec la valeur de i.
gbinforme
Messages postés
14946
Date d'inscription
lundi 18 octobre 2004
Statut
Contributeur
Dernière intervention
24 juin 2020
4 716
20 nov. 2017 à 21:29
20 nov. 2017 à 21:29
Bonjour,
Ta macro arrangée à ma façon : tu vérifies le n° de départ et celui de fin
Ta macro arrangée à ma façon : tu vérifies le n° de départ et celui de fin
Sub importer() Dim i As Long, ligne As Long Const deb = 1021 ' fiche début - 2 (à ajuster) For i = 2 To 9000 On Error Resume Next With Sheets("TEMP").QueryTables.Add(Connection:= _ "URL;http://www.mineralinfo.fr/Fiches/carmat/" & i + deb, Destination:=Sheets("TEMP").Range( _ "$A$1")) .Name = "4" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With If Err.Number = 0 Then For ligne = 1 To 100 If Left(Sheets("TEMP").Cells(ligne, 1), 3) = "Nom" Then Sheets("ACCUEIL").Cells(i, 1) = Mid(Sheets("TEMP").Cells(ligne, 1), 7) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 9) = "Exploitée" Then Sheets("ACCUEIL").Cells(i, 2) = Mid(Sheets("TEMP").Cells(ligne, 1), 16) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 5) = "Fiche" Then Sheets("ACCUEIL").Cells(i, 3) = Mid(Sheets("TEMP").Cells(ligne, 1), 9) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 11) = "Département" Then Sheets("ACCUEIL").Cells(i, 4) = Mid(Sheets("TEMP").Cells(ligne, 1), 14) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 6) = "Commune" Then Sheets("ACCUEIL").Cells(i, 5) = Mid(Sheets("TEMP").Cells(ligne, 1), 10) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 6) = "Code P" Then Sheets("ACCUEIL").Cells(i, 6) = Mid(Sheets("TEMP").Cells(ligne, 1), 14) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 6) = "Numéro" Then Sheets("ACCUEIL").Cells(i, 7) = Mid(Sheets("TEMP").Cells(ligne, 1), 8) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 6) = "Code B" Then Sheets("ACCUEIL").Cells(i, 8) = Mid(Sheets("TEMP").Cells(ligne, 1), 12) ElseIf Left(Sheets("TEMP").Cells(ligne, 4), 3) = "Fin" Then Sheets("ACCUEIL").Cells(i, 9) = Sheets("TEMP").Cells(ligne + 1, 4) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 6) = "Statut" Then Sheets("ACCUEIL").Cells(i, 10) = Mid(Sheets("TEMP").Cells(ligne, 1), 10) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 4) = "Type" Then Sheets("ACCUEIL").Cells(i, 11) = Mid(Sheets("TEMP").Cells(ligne, 1), 20) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 13) = "Réaménagement" Then Sheets("ACCUEIL").Cells(i, 12) = Mid(Sheets("TEMP").Cells(ligne, 1), 17) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 7) = "Hauteur" Then Sheets("ACCUEIL").Cells(i, 13) = Mid(Sheets("TEMP").Cells(ligne, 1), 28) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 9) = "Epaisseur" Then Sheets("ACCUEIL").Cells(i, 14) = Mid(Sheets("TEMP").Cells(ligne, 1), 25) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 10) = "Profondeur" Then Sheets("ACCUEIL").Cells(i, 15) = Mid(Sheets("TEMP").Cells(ligne, 1), 23) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 7) = "Surface" Then Sheets("ACCUEIL").Cells(i, 16) = Mid(Sheets("TEMP").Cells(ligne, 1), 28) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 8) = "Géologie" Then Sheets("ACCUEIL").Cells(i, 17) = Mid(Sheets("TEMP").Cells(ligne, 1), 30) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 9) = "Typologie" Then Sheets("ACCUEIL").Cells(i, 18) = Mid(Sheets("TEMP").Cells(ligne, 1), 13) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 3) = "Age" Then Sheets("ACCUEIL").Cells(i, 19) = Mid(Sheets("TEMP").Cells(ligne, 1), 33) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 11) = "Morphologie" Then Sheets("ACCUEIL").Cells(i, 20) = Mid(Sheets("TEMP").Cells(ligne, 1), 15) ElseIf Left(Sheets("TEMP").Cells(ligne, 1), 10) = "Lithologie" Then Sheets("ACCUEIL").Cells(i, 21) = Mid(Sheets("TEMP").Cells(ligne, 1), 43) End If Next ligne Sheets("Temp").Cells.ClearContents Else Err.Clear End If Next i End Sub
maximegeomat
Messages postés
1
Date d'inscription
lundi 20 novembre 2017
Statut
Membre
Dernière intervention
21 novembre 2017
21 nov. 2017 à 11:02
21 nov. 2017 à 11:02
Merci gbinforme pour cette réponse rapide et ce script super efficace.
Sujet Résolue !!
Sujet Résolue !!
gbinforme
Messages postés
14946
Date d'inscription
lundi 18 octobre 2004
Statut
Contributeur
Dernière intervention
24 juin 2020
4 716
21 nov. 2017 à 11:39
21 nov. 2017 à 11:39
Merci du retour et content de t'avoir aider à solutionner ton projet.