Ortak_Akıl
Yeni Üye
- Katılım
- 1 Haz 2023
- Mesajlar
- 225
- Çözümler
- 23
- Aldığı beğeni
- 105
- Excel V
- Office 2013 TR
Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı ya da giriş yapmalısınız. Foruma üye olmak tamamen ücretsizdir.
Dim oIE As InternetExplorer
Dim oHDoc As HTMLDocument
Private Sub CommandButton1_Click()
On Error Resume Next
Dim oIE As InternetExplorer
Dim oHDoc As HTMLDocument
Dim y, x As Integer, z As Integer, ss As Long, sonakaryakitdegeri As Long
Dim ara As Range
Const strURL As String = "EBİS Bildirim Sistemi"
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.Calculation = xlAutomatic
Application.DisplayAlerts = False
Set ara = Range("B:B").Find(What:=CDate(Format(Now, "dd.mm.yy")))
sonakaryakitdegeri = Range("c" & Rows.Count).End(xlUp).Row
If Not ara Is Nothing Then
ss = ara.Row
Else: MsgBox "Bugünün fiyatı boş olduğu için makro çalışmaz", vbInformation, "ExcelCozum.com"
GoTo 0
End If
If ss < 3 Then Exit Sub
y = Range("B3:C" & ss).Value
Set oIE = New InternetExplorer
With oIE
.Visible = False
.Navigate strURL
End With
Do While oIE.Busy = True Or oIE.readyState <> 4
DoEvents
Loop
Set oHDoc = oIE.Document
For i = sonakaryakitdegeri To UBound(y)
If y(i, 2) = "" Then
x = x + 1
valTrh = CStr(Format(y(i, 1), " dd.mm.yyyy"))
If valTrh = "" Then Exit For
oHDoc.getElementById("bultenKriterleriForm:j_idt30_input").Value = valTrh
oHDoc.getElementById("bultenKriterleriForm:j_idt32").Click
Do While oIE.Busy = True Or oIE.readyState <> 4 Or oIE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:01"))
With oHDoc.getElementsByTagName("table")(5)
y(i, 2) = CDbl(Evaluate(.Rows(3).Cells(1).innerText))
If y(i, 2) = "" Then z = z + 1
End With
End If
Next i
If x > 0 Then
Cells(3, "B").Resize(UBound(y), 2) = y
If z > 0 Then MsgBox z & " Adet boş Akaryakıt fiyatları bulunamamıştır", vbInformation, "ExcelCozum.com"
GoTo 0
Else
MsgBox "Boş Akaryakıt fiyatları bulunamamıştır", vbInformation, "ExcelCozum.com"
GoTo 0
End If
MsgBox "İşlem tamam.", vbInformation, "ExcelCozum.com"
0:
oIE.Quit
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
oIE.Quit
Set oIE = Nothing
Set oHDoc = Nothing
Set xlSht = Nothing
End Sub
Private Sub CommandButton1_Click()
On Error Resume Next
Dim oIE As InternetExplorer
Dim oHDoc As HTMLDocument
Dim y, x As Integer, z As Integer, ss As Long, sonakaryakitdegeri As Long
Dim ara As Range
Const strURL As String = "https://bildirim.epdk.gov.tr/bildirim-portal/faces/pages/tarife/petrol/yonetim/bultenSorgula.xhtml"
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Application.Calculation = xlAutomatic
Application.DisplayAlerts = False
Set ara = Range("B:B").Find(What:=CDate(Format(Now, "dd.mm.yy")))
sonakaryakitdegeri = Range("C" & Rows.Count).End(xlUp).Row
If Not ara Is Nothing Then
ss = ara.Row
Else: MsgBox "Bugünün fiyatı boş olduğu için makro çalışmaz", vbInformation, "ExcelCozum.com"
GoTo 0
End If
If ss < 3 Then Exit Sub
y = Range("B3:C" & ss).Value
Set oIE = New InternetExplorer
With oIE
.Visible = False
.Navigate strURL
End With
Do While oIE.Busy = True Or oIE.readyState <> 4
Loop
Set oHDoc = oIE.Document
For i = sonakaryakitdegeri To ss
If y(i - 1, 2) = "" Then
x = x + 1
valTrh = CStr(Format(y(i - 1, 1), " dd.mm.yyyy"))
If valTrh = "" Then Exit For
oHDoc.getElementById("bultenKriterleriForm:j_idt30_input").Value = valTrh
oHDoc.getElementById("bultenKriterleriForm:j_idt32").Click
Application.Wait (Now + TimeValue("0:00:01"))
Do While oIE.Busy = True Or oIE.readyState <> 4 Or oIE.readyState <> READYSTATE_COMPLETE
Loop
With oHDoc.getElementsByTagName("table")(5)
deg = CDbl(Evaluate(.Rows(3).Cells(1).innerText))
If deg = "" Or deg = y(i - 2, 2) Then Application.Wait (Now + TimeValue("0:00:01"))
y(i - 1, 2) = deg
If deg = "" Then z = z + 1
End With
End If
Next i
If x > 0 Then
Cells(3, "B").Resize(UBound(y), 2) = y
If z > 0 Then MsgBox z & " Adet boş Akaryakıt fiyatları bulunamamıştır", vbInformation, "ExcelCozum.com"
GoTo 0
Else
MsgBox "Boş Akaryakıt fiyatları bulunamamıştır", vbInformation, "ExcelCozum.com"
GoTo 0
End If
MsgBox "İşlem tamam.", vbInformation, "ExcelCozum.com"
0:
oIE.Quit
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
oIE.Quit
Set oIE = Nothing
Set oHDoc = Nothing
Set xlSht = Nothing
End Sub
Dim oIE As InternetExplorer
Dim oHDoc As HTMLDocument