PDA

View Full Version : VBA-code Import from website to excel



Mverm0
06-26-2014, 01:03 AM
Overheidinnederland.nl import to excel


Hi guys,


I have a site look at vba-code.


On this site you can select a 'provincie' (dutch word).

Their are twelve of them. The list is right of the map of the Netherlands.

Drenthe
Flevoland
Friesland
Gelderland
Groningen
Limburg
Noord-Brabant
Noord-Holland
Overijssel
Utrecht
Zeeland
Zuid-Holland

Let's click on the first on, Drenthe. Under the map of Drenthe you get a list of 'Gemeenten' (dutch-word).
Aa en Hunze
Assen
Borger-Odoorn
Coevorden
De Wolden
Emmen
Hoogeveen
Meppel
Midden-Drenthe
Noordenveld
Tynaarlo
Westerveld

Let's click on Aa en Hunze. You get three pages in total 29 results with persons who share their name and function under the header 'Totaaloverzicht' (dutch-word). I would like to import these data to excel. Is their a VBA-code to do this easy?

I'll be very grateful.

I made a start of a VBA-script:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Row = Range("Provincie").Row And _
Target.Column = Range("Provincie").Column Then
Dim IE As New InternetExplorer
'IE.Visible = True
IE.navigate "h t t p" overheidinNederland . nl=" & Range("nederland_map").Value
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Dim Doc As HTMLDocument
Set Doc = IE.document
Dim sDD As String
sDD = Trim(Doc.getElementsByTagName("li").innerText)
IE.Quit
Add = Split(sDD, ", ")
Range("Naam").Value = Add(1)
Range("Functie").Value = Add(2)
Range("Gemeente").Value = Add(0)
MsgBox sDD
End If
End Sub