'OPHALEN UITSLAGEN VAN SITE GELRE
Dim IE As SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
Dim IE2 As SHDocVw.InternetExplorer
Set IE2 = New SHDocVw.InternetExplorer
Dim IE3 As SHDocVw.InternetExplorer
Set IE3 = New SHDocVw.InternetExplorer
Dim varTables, varTable
Dim varRows, varRow
Dim varCells, varCell
Dim lngRow As Long, lngColumn As Long
Dim txt As String
Dim k As Long
Dim m As Long
Dim l As Long
Sheets("links").Select
Range("a1").Select
URL = "http://www.nttbgelre.nl/"
IE.Visible = True
IE.Navigate URL
Do While IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set d = IE.Document
For k = 0 To d.Links.Length - 1
'write the linking url to a cell
Cells(k + 1, 1).Value = d.Links(k).href
Cells(k + 1, 2).Value = d.Links(k).innerText
Next k
Range("B1").Select
Cells.Find(What:="senioren", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
URL2 = ActiveCell.Offset(0, -1).Value
IE2.Navigate URL2
Do While IE2.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
IE2.Visible = True
Set d2 = IE2.Document
Sheets("links").Select
Range("A1").Select
For m = 0 To d2.Links.Length - 1
'write the linking url to a cell
Cells(m + 1, 1).Value = d2.Links(m).href
Cells(m + 1, 2).Value = d2.Links(m).innerText
Next m
Range("B1").Select
Cells.Find(What:="standen ", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
URL3 = ActiveCell.Offset(0, -1).Value
IE3.Navigate URL3
Sheets("alle standen senioren").Select
Range("A1").Select
Do While IE3.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
IE3.Visible = True
Set d3 = IE3.Document
d3.all.Item("select1").selectedIndex = "51"
d3.all("submit").Click
Do While IE3.Busy:
DoEvents:
Loop
Dim Coltables As Object
Dim Rij As Object
Dim Cell As Object
Dim Waarde As String
Set Coltables = d3.getElementsByTagName("TABLE")
Dim i As Long
Dim j As Long
Dim i2 As Long
Set Rij = Coltables(9).getElementsByTagName("TR")
i2 = 1
For i = 0 To Rij.Length - 1
Set Cell = Rij(i).getElementsByTagName("TD")
For j = 0 To Cell.Length - 1
Waarde = Cell(j).innerText
ActiveCell.Value = Waarde
ActiveCell.Offset(0, 1).Select
Next j
i2 = i2 + 1
Range("A" & i2).Select
Next i
IE.Quit
Set IE = Nothing
IE2.Quit
Set IE2 = Nothing
IE3.Quit
Set IE3 = Nothing