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

[µo°Ý] ¦¹vba¨«§¹¡A¾ã­Óexcel¦n¹³lag¤F¡A¤£¾å±o¥i¥H«ç¼Ë­×§ï

[µo°Ý] ¦¹vba¨«§¹¡A¾ã­Óexcel¦n¹³lag¤F¡A¤£¾å±o¥i¥H«ç¼Ë­×§ï

Sub GGetPrice()
    Dim DataQ As Integer, DQQ As Integer, DQ As Integer
    Dim StartYear, LastYear, CycleNumber, StockNumber As Integer
   
    StartYear = 2010
    LastYear = 2013
    CycleNumber = 1
    StockNumber = 1101
   
    Sheets("sheet7").Select  '²M°£±ý¦s©ñªº­¶­±
    Cells.Clear
   
    For DP = StartYear To LastYear
   
    Sheets("sheet7").Range("a1").Value = DP
   
   
        For DQ = 9 To 12
            
        Sheets("sheet6").Select        
        Cells.Clear                                '²M°£§ì¨ú¸ê®Æ¦s©ñªº­¶­±

       [b1] = DQ
       [a1] = Sheets("sheet7").Range("a1").Value
      
       If DQ <= 9 Then
        With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/genpage/Report" & [a1] & "0" & [b1] & "/" & [a1] & "0" & [b1] & "_F3_1_8_" & StockNumber & ".php?STK_NO=" & StockNumber & "&myear=" & [a1] & "&mmon=0" & [b1] & "", Destination:=Selection) '·s¼W¬d¸ß
      
        Range("a2").Select
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables         
        .WebFormatting = xlWebFormattingNone
        .WebTables = "8"                                
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        '.Refresh BackgroundQuery:=False
        '.Name = .ResultRange.Cells(1, 1)
        
        '' ¹J¨ì¿ù»~Ä~Äò°õ¦æ
              On Error Resume Next
              '' ºô­¶¿ù»~·|¦b³o¦æ¥á¥X¿ù»~½X¦b Err.Numer ¤¤
              .Refresh BackgroundQuery:=False
              If Err.Number Then
                '' ²M°£¿ù»~°T®§, ¨Ã¥B¦^´_¹w³]ªº¿ù»~³B²zµ{§Ç, Ä~Äò¶]¤U¤@¤Ñªº¸ê®Æ
                Err.Clear
                On Error GoTo 0
         
              End If
              '' ¦^´_¹w³]ªº¿ù»~³B²zµ{§Ç
              On Error GoTo 0

        Worksheets("sheet6").Select
        Range("A4:i30").Select
        Selection.Copy
   
        Data = 3 + (CycleNumber - 1) * 30
        Sheets("sheet7").Select
        Range("a" & Data).Select               
        ActiveSheet.Paste
                  
        CycleNumber = CycleNumber + 1
        
        End With
   
    Else
      
       With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.twse.com.tw/ch/trading/exchange/STOCK_DAY/genpage/Report" & [a1] & "" & [b1] & "/" & [a1] & "" & [b1] & "_F3_1_8_" & StockNumber & ".php?STK_NO=" & StockNumber & "&myear=" & [a1] & "&mmon=" & [b1] & "", Destination:=Selection)  '·s¼W¬d¸ß
      
         
         Range("a2").Select
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables           
        .WebFormatting = xlWebFormattingNone
        .WebTables = "8"                              
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        '.Refresh BackgroundQuery:=False
        '.Name = .ResultRange.Cells(1, 1)
        
        '' ¹J¨ì¿ù»~Ä~Äò°õ¦æ
              On Error Resume Next
              '' ºô­¶¿ù»~·|¦b³o¦æ¥á¥X¿ù»~½X¦b Err.Numer ¤¤
              .Refresh BackgroundQuery:=False
              If Err.Number Then
                '' ²M°£¿ù»~°T®§, ¨Ã¥B¦^´_¹w³]ªº¿ù»~³B²zµ{§Ç, Ä~Äò¶]¤U¤@¤Ñªº¸ê®Æ
                Err.Clear
                On Error GoTo 0
         
              End If
              '' ¦^´_¹w³]ªº¿ù»~³B²zµ{§Ç
              On Error GoTo 0
                           
        Worksheets("sheet6").Select
        Range("A7:i37").Select
        Selection.Copy
   
        Data = 3 + (CycleNumber - 1) * 30
        Sheets("sheet7").Select
        Range("a" & Data).Select               
        ActiveSheet.Paste
               
        CycleNumber = CycleNumber + 1
      
                 
    End With
    End If
   
   
    Next DQ
    Next DP
    End Sub

¦Ó¬°¤F²M°£¤£¥²­nªº¸ê®Æ¡A¼g¤F¥H¤U¡A¦ý¬åªº«ÜºC¡A¤£¾å±o­n¦p¦ó­×¥¿¡AÁÂÁ¡I

    Sub DeleteLine()
   
    Dim keyword As String
    Dim EndLine As Integer
   
    Sheets("sheet7").Select
   
    keyword = "endword"
    EndLine = 357
   
    Range("a" & EndLine + 1).Value = keyword
    cat = 0
   
    For i = 1 To EndLine
   
     keyword = "¥xªd"                                       '§PÂ_¦³µL¿é¤J¤å¦r
   
    If Range("A" & i).Value Like "*" & keyword & "*" Then
    Rows(i).Delete Shift:=xlUp
    Else
    End If
   
   
    If Range("a" & i).Value <> "(¤¸,ªÑ)" Then
    Else
    Rows(i).Delete Shift:=xlUp
    End If
   
    If Range("a" & i).Value <> "¤é´Á" Then
     Else
    Rows(i).Delete Shift:=xlUp
    End If
   
    For Q = 1 To 9
    If Range("a" & i).Value <> "" Then
     Else
    Rows(i).Delete Shift:=xlUp
    End If
    Next Q
   
    If Range("a" & i).Value <> "endword" Then
   
    Else
    i = EndLine
    End If
      
    'If cat = 1 Then
    'i = i - 1
    'Else
    'End If
   
    Next i
   
    Range("a1").Select
   
End Sub

TOP

ÁÂÁÂhandsometrowa¤jªºÃö¤ß¡A¥¿­npo ¤W¨Ó¡A
¨S®Æ¨ìµ½¸Ñ¤H·NªºGBKEE¤j¤w±N¤p§Ìªº°ÝÃD¤@¨Ö¥þ¸Ñ¤F¡A
¦hÁ¨â¦ì¡ã

¦ýGBKEE¤j¡A½Ð°Ý¤@¤U¡A¤WÂdªº¸ê®Æ­n«ç¼Ë¼g¶i¨Ó¡CÁÂÁ¡I

TOP

http://www.otc.org.tw/ch/stock/aftertrading/daily_trading_info/st43.php
¦ý¤WÂdªººô§}¦³²§¡A­n¿é¤J¦~¤ë¤é ¡® ¥N¸¹¡AµM«á«ö¤U¬d¸ß¡C
§Ú¦A¨Ó·Q·Q¬Ý

TOP

        ÀR«ä¦Û¦b : §g¤l¦p¤ô¡AÀH¤è´N¶ê¡AµL³B¤£¦Û¦b¡C
ªð¦^¦Cªí ¤W¤@¥DÃD