J'ai le tableau suivant dans excel où col1 = ID du film, col2 = nom du film. J'essaie d'utiliser la requête Web Excel pour get le nom de l'entreprise de production de tous les films de ma list.
ID Movie Name tt1540741 A Single Shot (2013) tt4630158 A Space Program (2015 Documentary)
Par exemple http://www.omdbapi.com/?i=tt2330270&tomatoes=true&plot=short&r=xml
Le lien renverra un XML contenant le nom de l'entreprise de production.
Je ne suis pas sûr de comment écrire la formule Excel qui atteindra cet objective.
(Je veux que la sortie ressemble à celle-ci)
ID Movie Name Production firm tt1540741 A Single Shot (2013) ABC tt4630158 A Space Program (2015 Documentary) DEF
Problème résolu. Voici ma solution. Notez que les numéros de ligne sont fixés ici, vous pouvez le modifier pour être dynamic.
La colonne A contient ici toute l'URL avec une ID de film unique. Par exemple
http://www.omdbapi.com/?i=tt0811137&tomatoes=true&plot=short&r=xml
Sub getMovieInfo() ' Application.ScreenUpdating = False Dim x As Integer ' Set numrows = number of rows of data. NumRows = 1491 ' Select cell a1. Range("A1").Select ' Establish "For" loop to loop "numrows" number of times. For x = 1 To 1491 ' Insert your code here. pos = "A" & x des = "$D" & x ActiveWorkbook.XmlImport URL:=Cells.Item(x, "A"), _ ImportMap:=Nothing, Overwrite:=True, Destination:=Sheets("Sheet3").Range(des) ' Sheets("Sheet1").Range(des).Value = Cells.Item(x, "A") Application.Wait (Now + TimeValue("00:00:2")) If (IsEmpty(Sheets("sheet3").Range(des)) = True) Then Application.Wait (Now + TimeValue("00:00:10")) If (IsEmpty(Sheets("sheet3").Range(des)) = True) Then Exit Sub End If End If ActiveCell.Offset(1, 0).Select Next End Sub