¡@¼ÊºÙ: ¨F©Ôªo ¡@ÀY»Î: ¥¿´äA¤ô¹q¤u
¶W¯Åª©¥D
- ©«¤l
- 44
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 49
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows XP SP3
- ³nÅ骩¥»
- Office 2003
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- §b¤Y
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2013-1-27
|
¥»©«³Ì«á¥Ñ ¨F©Ôªo ©ó 2011-1-21 23:40 ½s¿è
¤£«OÃÒ¦^¶Ç¸ê®Æªº§¹¾ã©Ê- Sub webqyt()
- Dim qyt As QueryTable
- Dim sh As Worksheet
- Dim i As Integer
- Dim para As String
- Dim paras As Variant
- Dim rng As Range
-
- paras = Array("ªÑ²¼¥N¸¹", "¶}©l¤é´Á¡]¦è¤¸¡^", "µ²§ô¤é´Á¡]¦è¤¸¡^")
- Application.ScreenUpdating = False
- Set sh = Sheets.Add
- '«Ø¥ßWEB¬d¸ß
- Set qyt = sh.QueryTables.Add(Connection:= _
- "FINDER;http://oilonline.myweb.hinet.net/m.iqy", _
- Destination:=Range("A1"))
- '³]©w°Ñ¼Æ 1 to 3
- For i = 1 To 3
- para = InputBox("½Ð¿é¤Jn¬d¸ßªº" & paras(i - 1), "¬d¸ß°Ñ¼Æ " & i & "/3")
- Select Case i
- Case 1: If Not IsNumeric(para) Then GoTo ERROUT
- Case 2: If Not IsDate(para) Then GoTo ERROUT
- Case 3: If Not IsDate(para) Then GoTo ERROUT
- End Select
- qyt.Parameters(i).SetParam xlConstant, IIf(i > 1, Format(para, "yyyy-m-d"), para)
- Next
- Sheet1.Cells.Clear
- i = 1
- '¶}©l¬d¸ß
- Do
- qyt.Parameters(4).SetParam xlConstant, i
- qyt.Refresh False
- With qyt.ResultRange
- If .Rows.Count > 4 Then
- Set rng = Range("A" & IIf(i = 1, 1, 3)).Resize(.Rows.Count - IIf(i = 1, 2, 4), .Columns.Count)
- rng.Copy Sheet1.Range("A65536").End(xlUp).Offset(IIf(i = 1, 0, 1), 0)
- End If
- End With
- Set rng = Cells.Find(what:="¤U¤@¶", LookIn:=xlValues, Lookat:=xlPart)
- i = i + 1
- Loop While Not rng Is Nothing
- Application.DisplayAlerts = False
- sh.Delete
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- Exit Sub
- ERROUT:
- Application.DisplayAlerts = False
- sh.Delete
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "§A´£¨Ñªº¸ê®Æ©úÅ㤣¥¿½T¡A¤£¬d¤F¡ã"
- End Sub
½Æ»s¥N½X ¦h¬Ý¬Ýµ{¦¡½Xªº·N¸q¡A¤£n¥u¬O½Æ»s¦^¥h¯à¥Î´Nºâ¤F¡A
¤U¦¸¦P¼Ëªº°ÝÃD´N¤£µª¤F¡ã |
|