Arkadaşlar Web sayfasından veri alırken aşağıdaki kodla web sitesindeki 5. tablodaki verileri excele aktarıyorum. Ancak 5.tablo içerisinde alt alta satırlar var ve veri alırken ben sadece ilk satırı (en üst satırı da diyebilirim) almak istiyorum. Nasıl yapabilirim.
Dim y As Long, z As Long, wb As Excel.Workbook, ws As Excel.Worksheet
Set wb = Excel.ActiveWorkbook
Set ws = wb.ActiveSheet
y = 2 'Column A in Excel
z = 1 'Row 1 in Excel
Do While IE.Busy: DoEvents: Loop
Do While IE.ReadyState <> 4: DoEvents: Loop
Set doc = IE.Document
Set hTable = doc.GetElementsByTagName("table")
Set tb = hTable(5)
Set hBody = tb.GetElementsByTagName("tbody")
For Each bb In hBody
Set hTR = bb.GetElementsByTagName("tr")
For Each tr In hTR
Set hTD = tr.GetElementsByTagName("td")
y = 2 ' Resets back to column A
For Each td In hTD
ws.Cells(i, y).Value = td.innertext
y = y + 1
Next td
DoEvents
z = z + 1
Next tr
Next bb
Dim y As Long, z As Long, wb As Excel.Workbook, ws As Excel.Worksheet
Set wb = Excel.ActiveWorkbook
Set ws = wb.ActiveSheet
y = 2 'Column A in Excel
z = 1 'Row 1 in Excel
Do While IE.Busy: DoEvents: Loop
Do While IE.ReadyState <> 4: DoEvents: Loop
Set doc = IE.Document
Set hTable = doc.GetElementsByTagName("table")
Set tb = hTable(5)
Set hBody = tb.GetElementsByTagName("tbody")
For Each bb In hBody
Set hTR = bb.GetElementsByTagName("tr")
For Each tr In hTR
Set hTD = tr.GetElementsByTagName("td")
y = 2 ' Resets back to column A
For Each td In hTD
ws.Cells(i, y).Value = td.innertext
y = y + 1
Next td
DoEvents
z = z + 1
Next tr
Next bb