ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] QueryTables ¬d¸ßªÑ²¼°ÝÃD

[µo°Ý] QueryTables ¬d¸ßªÑ²¼°ÝÃD

¦U¦ì°ª¤â±M®a¦n

¤p§Ì¦b¨Ï¥ÎQueryTable ®É¡A
·|¦b³sÄò¬d¸ß¼Æµ§¸ê®Æ¤§«á¬ðµMµo¥Í 400 ªº¿ù»~¡A¦Ó³y¦¨¸ê®Æ¤@ª½¬d¤£§¹¡A·Q½Ð±Ð¬Oµo¥Í¤°»ò°ÝÃD©O?
µ{¦¡½X©MªþÀɦp¤U ·PÁ¦^ÂÐ

Sub §ì¨úªÑ²¼¸ê®Æ()
    Dim StartTime
    Dim i
    Dim j
    Dim StockNumber As String 'ªÑ²¼¥N¸¹
   
    i = 2
   
    If ½T»{¤u§@ªí¦s¦b("Temp") <> True Then
        Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Temp"
    End If
   
    Application.ScreenUpdating = False
        
    ²M°£¤u§@ªí ("Temp")
   
    Set Tempsheet = Sheets("Temp")
   
    Do While Sheet1.Cells(i, 1) <> ""
         If Sheet1.Cells(i, 2) = "" Then
         
                StockNumber = Sheet1.Cells(i, 1)
                GetCurrentPrice (StockNumber)
        End If
      
                    Sheet1.Cells(i, 2) = StockName
                    Sheet1.Cells(i, 3) = CurrentPrice
                    Sheet1.Cells(i, 4) = PriceChange
                    Sheet1.Cells(i, 5) = StockQuantity
        i = i + 1
    Loop
   
    Application.StatusBar = "ªÑ²¼¸ê®Æ§ì¨ú§¹¦¨"
    Application.ScreenUpdating = True

    Sheet1.Activate
    Sheets("Temp").Delete
End Sub

Sub GetCurrentPrice(StockNumber As String)

    Dim ur As String

    Application.StatusBar = "¨ú±oªÑ²¼ " & StockNumber & " ªÑ»ù¸ê®Æ¤¤......"
   
    ur = "https://tw.finance.yahoo.com/q/q?s=" & StockNumber
   ' MsgBox ur
   
        Tempsheet.Range("A:L").Clear

        With Tempsheet.QueryTables.Add(Connection:="URL;" & ur, Destination:=Tempsheet.Range("A1"))
            .WebSelectionType = xlSpecifiedTables
            .WebFormatting = xlWebFormattingNone
            .WebTables = "6"
            .Refresh BackgroundQuery:=False
            .Delete
         End With
   
       StockName = Tempsheet.Cells(3, 1)
       CurrentPrice = Tempsheet.Cells(3, 3)
       PriceChange = Tempsheet.Cells(3, 6)
       StockQuantity = Tempsheet.Cells(3, 7)

End Sub

Book1.zip (19.95 KB)

¦^´_ 1# morrishou
  1. ªí³æ¤v¸gÅã¥Ü¡F¤£¯à¦A¥H±j¨î¦^À³ªº¤è¦¡Åã¥Ü¦¹ªí³æ (¿ù»~ 400)
½Æ»s¥N½X
ªþÀɨS¦³ªí³æ,2003¤U°õ¦æ§Aªºµ{¦¡¨S¬Ý¨ì(¿ù»~ 400)
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD