em có macro thế này em muốn lấy KQXS từ trang minhngoc.net.vn thì e phải sửa thế nào ah? mong các pác giúp em với.
Sub GetLotteryResultVersion2()
On Error GoTo ERH
Dim nIndex As Integer
Dim strTP As String 'Ma tinh/thanh pho
Dim strDateInput As String
Dim dStartDate, dEndDate, dQueryDate As Date
Dim nInterval As Integer
Dim nRow As Integer
strDateInput = InputBox("Tu ngay : (la ngay bat dau lay ket qua xo so, nhap theo dang dd-MMM-yyyy" & vbCrLf & "VD : 01-Jan-2008" & vbCrLf & "Neu kg nhap se lay mac dinh la ngay 01-Jan-2008", "Tu ngay", "01-jan-2008")
dStartDate = CDate(strDateInput) 'Ngay bat dau co du lieu trong database cua xsbinhduong
dEndDate = Date 'Ngay hom nay
nInterval = dEndDate - dStartDate 'Khoang cach theo ngay
strTP = 53 'strTP = InputBox("Ma Tinh/Thanh Pho : chi tiet ma Tinh va ma Thanh Pho xem trong wwww.xosobinhduong.com.vn" & vbCrLf _
& "1 : Binh Duong" & vbCrLf _
& "9 : Vinh Long" & vbCrLf _
& "10: Tra Vinh" & vbCrLf _
& "11: Dong Nai" & vbCrLf _
& "12: Can Tho" & vbCrLf _
& "13: Soc Trang" & vbCrLf _
& "14: Ben Tre" & vbCrLf _
& "15: Vung Tau" & vbCrLf _
& "16: Bac Lieu" & vbCrLf _
& "17: Binh Thuan " & vbCrLf _
& "18: Tay Ninh" & vbCrLf _
& "19: An Giang" & vbCrLf _
& "20: TP.HCM" & vbCrLf _
& "21: Dong Thap" & vbCrLf _
& "22: Ca Mau" & vbCrLf _
& "23: Tien Giang" & vbCrLf _
& "24: Kien Gian" & vbCrLf _
& "25: Binh Phuoc" & vbCrLf _
& "27: Hau Giang" & vbCrLf _
& "......................" _
, "Ma Tinh/TP", "1") '1= Binh Duong
For nIndex = 0 To nInterval
dQueryDate = DateAdd("d", nIndex, dStartDate)
nRow = GetRow(nIndex)
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.xosobinhduong.com.vn/Forms/XemKetQuaXoSo.aspx?Ngay=" & Format(dQueryDate, "dd/mm/yyyy") & "&TP=" & strTP _
, Destination:=Range("A" & nRow))
.Name = CStr(dQueryDate)
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
For j = nRow To nRow + 11
If Cells(j, "B") <> "" Then Cells(j, "C") = Format(dQueryDate, "dd-MMM-yyyy")
Next j
Debug.Print CStr(Format(dQueryDate, "dd/mm/yyyy"))
Next nIndex
MsgBox "OK, xong!", vbOKOnly
Exit Sub
ERH:
MsgBox Err.Description, vbOKOnly
End Sub