Documente Academic
Documente Profesional
Documente Cultură
Option Explicit
Sub importhn()
Dim dt As Date
Dim sheet As Worksheet
Dim arr
Dim nr, br50, i, hnfn, a, hi, hni, brc, noh, dd, mm, yyyy As Integer
Dim ie As Object
Dim url As String
'Dim ie As InternetExplorer
Dim html As HTMLDocument
Dim hn(88)
dt = Sheets("Main").Range("c2").Value
dd = Day(dt)
If dd < 10 Then dd = "0" & dd
mm = Month(dt)
If mm < 10 Then mm = "0" & mm
yyyy = Year(dt)
For Each sheet In ActiveWorkbook.Worksheets
If sheet.Name = "Temp2" Then Worksheets("Temp2").Delete
Next sheet
Sheets.Add After:=ThisWorkbook.Sheets(4)
ActiveSheet.Name = "Temp2"
'<---import HMTL
ie.Quit
hni = 0
brc = 0
Sheets("VICAR").Select
noh = Range("n1").Value
hi = 0
Range("a2").Select
Do Until ActiveCell.Value = ""
hi = hi + 1
'Application.StatusBar = "3/4 Completed " & Int(hi / noh * 75) + 20 & "%"
Sheets("VICAR").Select
rhn = LCase(Trim(ActiveCell.Value))
hnfn = rhn
For i = 1 To Len(rhn)
If Mid(rhn, i, 1) = " " Then rhn = Left(rhn, i - 1) & "-" & Right(rhn, Len(rhn) -
i)
Next i
Sheets("Temp2").Select
a = ActiveCell.Value
i = 1
Do Until Mid(a, i, 26) = "js-bestOddsRunnerHorseName" Or i > Len(a)
i = i + 1
Loop
hnwa = Trim(hnwa)
Sheets(hnfn).Select
Cells.Select
Selection.NumberFormat = "@"
nf = pd & "3 Horse Data Section 2 " & Int(hi / noh * 100) & "% attempt " & nr
Name lf As nf
lf = nf
Range("A1").Select
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False 'True
.navigate hnwa ' should work for any URL
Do Until .readyState = 4: DoEvents: Loop
End With
Range("a1").Select
br50 = 0
ActiveCell.Value = Trim(ActiveCell.Value)
ActiveCell.Value = Application.WorksheetFunction.Clean(ActiveCell.Value)
'MsgBox (Len(Trim(ActiveCell.Value)))
If Len(Trim(ActiveCell.Value)) > 0 Then
br50 = 0
ActiveCell.Offset(1, 0).Select
End If
If Len(Trim(ActiveCell.Value)) = 0 Then
br50 = br50 + 1
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlUp
Range("a" & ActiveCell.Row).Select
End If
' Sheets("VICAR").Select
Loop
Range("a42").Select
nr = 0
Do Until Range("a42").Value <> "" Or nr > 10
nr = nr + 1
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False 'True
.navigate hnwa ' should work for any URL
Do Until .readyState = 4: DoEvents: Loop
End With
For i = 1 To nr
Application.Wait (Now + TimeValue("0:00:08"))
Next i
ie.ExecWB 17, 0 '// SelectAll
ie.ExecWB 12, 2 '// Copy selection
Range("A1").Select
Range("a1").Select
br50 = 0
ActiveCell.Value = Trim(ActiveCell.Value)
ActiveCell.Value = Application.WorksheetFunction.Clean(ActiveCell.Value)
'MsgBox (Len(Trim(ActiveCell.Value)))
If Len(Trim(ActiveCell.Value)) > 0 Then
br50 = 0
ActiveCell.Offset(1, 0).Select
End If
If Len(Trim(ActiveCell.Value)) = 0 Then
br50 = br50 + 1
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlUp
Range("a" & ActiveCell.Row).Select
End If
'Sheets("VICAR").Select
nf = pd & "3 Horse Data Section 2 " & Int(hi / noh * 100) & "% attempt " & nr
Name lf As nf
lf = nf
Loop
If nr > 10 Then a = 0 / 0
End If
Sheets("VICAR").Select
ActiveCell.Offset(1, 0).Select
Loop
'Application.StatusBar = "3/4 Completed 99%"
Sheets("Temp2").Delete
End Sub
Sub manu()
Range("A1").Select
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False 'True
.navigate hnwa ' should work for any URL
Do Until .readyState = 4: DoEvents: Loop
End With
'Name ThisWorkbook.Path & "/" & lf & ".txt" As ThisWorkbook.Path & "/299.txt"
Range("a1").Select
br50 = 0
ActiveCell.Value = Trim(ActiveCell.Value)
ActiveCell.Value = Application.WorksheetFunction.Clean(ActiveCell.Value)
'MsgBox (Len(Trim(ActiveCell.Value)))
If Len(Trim(ActiveCell.Value)) > 0 Then
br50 = 0
ActiveCell.Offset(1, 0).Select
End If
If Len(Trim(ActiveCell.Value)) = 0 Then
br50 = br50 + 1
Rows(ActiveCell.Row).Select
Selection.Delete Shift:=xlUp
Range("a" & ActiveCell.Row).Select
End If
Loop
Name lf As nf
End Sub