Çoklu sorgu

Katılım
30 Kasım 2018
Mesajlar
87
Excel Vers. ve Dili
2016
İyi günler,
Ben hiç bir bilgim olmamasına rağmen belki saçma oldu ama aşağıda yer alan kodu yazdım ve çok güzel de çalışıyor. Yanlız a sütunundaki bütün verileri sorgulayıp b ve c sütunlarına atmasını istiyorum. Şu anda sadece a2 deki tc numarasından sorgu yapıyor ve b2 ye adresi c2 ye ilçeyi yazıyor.. bütün sütunu aynı anda sorgulayıp atmasını istiyorum.
Yardım ederseniz sevinirim..

Sub Arama()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://............................."
IE.Width = 1500
IE.Height = 1000
IE.Visible = False
While IE.Busy
DoEvents
Wend

IE.document.getElementById("ctl04_ctlTCKimlikNo").Value = Range("A2")
Application.Wait Now + TimeValue("00:00:02")
IE.Visible = False
While IE.Busy
DoEvents
Wend

Set TrackID = IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search")
IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search").Click
IE.Visible = False
While IE.Busy
DoEvents
Wend

Range("B2") = IE.document.getElementById("ctl04_ctlAdresBilgi").Value
Range("C2") = IE.document.getElementById("ctl04_ctlIlIlce").Value
IE.Visible = False
While IE.Busy
DoEvents
Wend
IE.Quit

End Sub
 

YUSUF44

Destek Ekibi
Destek Ekibi
Katılım
4 Ocak 2006
Mesajlar
12,084
Excel Vers. ve Dili
İş : Ofis 365 - Türkçe
Ev: Ofis 365 - Türkçe
Aşağıdaki şekilde for next döngüsüyle olabilir:

PHP:
Sub Arama()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://............................."
IE.Width = 1500
IE.Height = 1000
IE.Visible = False
While IE.Busy
DoEvents
Wend
son = cells(rows.count, "A").end(3).row
For i = 2 to son
IE.document.getElementById("ctl04_ctlTCKimlikNo").Value = cells(i,"A")
Application.Wait Now + TimeValue("00:00:02")
IE.Visible = False
While IE.Busy
DoEvents
Wend

Set TrackID = IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search")
IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search").Click
IE.Visible = False
While IE.Busy
DoEvents
Wend

cells(i,"B") = IE.document.getElementById("ctl04_ctlAdresBilgi").Value
cells(i,"C") = IE.document.getElementById("ctl04_ctlIlIlce").Value
IE.Visible = False
While IE.Busy
DoEvents
Wend
next
IE.Quit

End Sub
 
Katılım
30 Kasım 2018
Mesajlar
87
Excel Vers. ve Dili
2016
çok teşekkür ederim. Güzel olmuş ve güzelde çalışıyor. Ellerine sağlık. Ancak “A” hücresi boşsa yani bir “tc” yoksa işlem yapmıyor. Eğer boşsa “B” ye “yok” yazmasını istiyorum.
Bide “A” hücresindeki tc’ ye ait bi adres yoksa yine çalışmıyor. Böyle bir durumda bizim sistem “id” si “ctl04_ctlMessageBox_lblMessage” olan bir uyarı veriyor. Eğer adres çıkmayıpta bu uyarı gelirse bunun “B” de yazmasını istiyorum. İnşallah çok şey istememişimdir.
Şimdiden teşekkür ederim..
 

YUSUF44

Destek Ekibi
Destek Ekibi
Katılım
4 Ocak 2006
Mesajlar
12,084
Excel Vers. ve Dili
İş : Ofis 365 - Türkçe
Ev: Ofis 365 - Türkçe
A sütunu boşsa B'ye yok yazma aşağıdaki şekilde olabilir. Hata mesajı kısmını bilmiyorum maalesef. Bunun için örnek dosya ve belirttiğiniz siteyi görmek gerekebilir.

PHP:
Sub Arama()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://............................."
IE.Width = 1500
IE.Height = 1000
IE.Visible = False
While IE.Busy
DoEvents
Wend
son = cells(rows.count, "A").end(3).row
For i = 2 to son
if cells(i,"A") = "" then
cells(i,"B") = "Yok"
else

IE.document.getElementById("ctl04_ctlTCKimlikNo").Value = cells(i,"A")
Application.Wait Now + TimeValue("00:00:02")
IE.Visible = False
While IE.Busy
DoEvents
Wend

Set TrackID = IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search")
IE.document.getElementById("ctl04_ctlKpsAdresPageCommand_CommandItem_Search").Click
IE.Visible = False
While IE.Busy
DoEvents
Wend

cells(i,"B") = IE.document.getElementById("ctl04_ctlAdresBilgi").Value
cells(i,"C") = IE.document.getElementById("ctl04_ctlIlIlce").Value
IE.Visible = False
While IE.Busy
DoEvents
Wend
end if
next
IE.Quit

End Sub
 
Katılım
30 Kasım 2018
Mesajlar
87
Excel Vers. ve Dili
2016
peki hata mesajı verdiği zaman hata yazabilirmi. Yok yazdığı gibi..
 

Haluk

𐱅𐰇𐰼𐰚
Katılım
7 Temmuz 2004
Mesajlar
12,304
Excel Vers. ve Dili
64 Bit 2010 - İngilizce
+
Google Sheets
+
JScript
Altın Üyelik Bitiş Tarihi
Sitenin adresini verirseniz başka alternatifler de üretilebilinir...

.
 
Katılım
30 Kasım 2018
Mesajlar
87
Excel Vers. ve Dili
2016
Sub Arama()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://.................................."
IE.Width = 1500
IE.Height = 1000
IE.Visible = True
While IE.Busy
DoEvents
Wend
son = Cells(Rows.Count, "A").End(3).Row
For i = 2 To son
If Cells(i, "A") = "" Then
Cells(i, "B") = "TC yaz"
Else
IE.document.getElementById("ctl02_ctlCriteriaControl_ctlTCKimlikNo").Value = Cells(i, "A")
IE.Visible = True
While IE.Busy
DoEvents
Wend
Set TrackID = IE.document.getElementById("ctl02_ctlPageCommand_CommandItem_Search")
IE.document.getElementById("ctl02_ctlPageCommand_CommandItem_Search").Click
IE.Visible = True
While IE.Busy
DoEvents
Wend
Cells(i, "B") = IE.document.getElementById("ctl02_ctlDataGrid").ValueCells(i, "C") = IE.document.getElementById("ctl02_ctlDataGrid").Value
IE.Visible = True
While IE.Busy
DoEvents
Wend
End If
Next
IE.Quit

End Sub


Tekrardan selamlar,
Yukarıdaki kodu ben başka bir şey çekmek için uyarladım kırmızıyla belirttiğim yere kadar geliyor sorguluyor fakat excele atmıyor. Yanlışı nerde yapıyorum bilemedim kod aşağıda. Burada yapmak istediğim “Ad” yazanı “B” sütununa, “Soyad” yazanı “C”, “Baba Adı” “D”, “Anne Adı” “E”, “Doğum Yıl” “F” ye yazsın istiyorum.
Bu arada hakkınızı helal edin yoruyorum sizi.
Şimdiden teşekkür ederim.



<td rowSpan=”1” colSpan=”1”>
<div>
<table align=”center” class=”Grid” id=”ctl02_ctlDataGrid” style=”WIDTH: 100%; BORDER-COLLAPSE: collapse; COLOR: #333333” cellSpacing=”0” cellPadding=”4”>
<tbody>
<tr align=”left” style=”FONT-WEIGHT: bold; COLOR: white; BACKGROUND-COLOR: #5d7b9d”>
<th rowSpan=”1” colSpan=”1” scope=”col></th>
<th rowSpan=”1” colSpan=”1” scope=”col>T.C. Kimlik No</th>
<th rowSpan=”1” colSpan=”1” scope=”col>Ad</th>
<th rowSpan=”1” colSpan=”1” scope=”col>Soyad</th>
<th rowSpan=”1” colSpan=”1” scope=”col>Baba Adı</th>
<th rowSpan=”1” colSpan=”1” scope=”col>Anne Adı</th>
<th rowSpan=”1” colSpan=”1” scope=”col>Doğum Yıl</th>
</tr>
<tr style=”COLOR: #333333; BACKGROUND-COLOR: #f7f6f3”>
<td rowSpan=”1” colSpan=”1”>…</td>
<td rowSpan=”1” colSpan=”1”>12345678901</td>
<td rowSpan=”1” colSpan=”1”>KADİR</td>
<td rowSpan=”1” colSpan=”1”>GÖRKEM</td>
<td rowSpan=”1” colSpan=”1”>ALİ</td>
<td rowSpan=”1” colSpan=”1”>AYŞE</td>
<td rowSpan=”1” colSpan=”1”>1982</td>
</tr>
 
Üst