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

[µo°Ý] µ{¦¡°õ¦æ³t«×¶V¨Ó¶VºC

[µo°Ý] µ{¦¡°õ¦æ³t«×¶V¨Ó¶VºC

¥»©«³Ì«á¥Ñ bulletin ©ó 2014-2-5 19:14 ½s¿è

¦U¦ì«e½ú¦n
¤p§Ìªì¾Ç¡AÁÙ¤£ª¾¹D­n«ç»ò³B²z¸ê®Æ®w
¦]¦¹¼g¤F¤@­Óµ{¦¡§ì¨ú¨é°Ó¤w¾ã²z¦nªº°]³ø
µ{¦¡¥i¥H°õ¦æ
¦ý¬Oµo²{´X­Ó°ÝÃD

1. ­Y¨S¦³¥t¦s·sÀÉ¡A¸ê®Æ¥i§ì¨ú¡A¦ý¬OÀHµÛ®É¶¡¹L¥h¡Aexcel·|¶VÅܶVºC, ±q¨Cµ§¬ù1¬íºCºCÅܦ¨1¤ÀÄÁ....
     ½Ð°Ý³o¦³¤°»ò¦n¤èªk¥i¥H§ïµ½¶Ü¡H
     ¥ý§â°]³ø§ì¤U¨Ó¤§«á¦A°µ¸ê®Æ¿z¿ï¨Ã¥t¦s¬O§_¬O¸û¦nªº¿ï¾Ü¡H
     
µù¡G¨S¦s·sÀÉ´N¬Oµ{¦¡³Ì¤U¤èªº³o´X¦æ§R°£

            Sheets(Array("CFSQ", "ISQ", "BSQ")).Copy
            ActiveWorkbook.SaveAs Filename:= _
              "C:\Users\user\Documents\KT\§ë¸ê²z°]\Excel¤ÀªR¼Ò²Õ\" & stockid & "©u³ø.xlsx", FileFormat:= _
               xlOpenXMLWorkbook, CreateBackup:=False
                       
            Application.DisplayAlerts = True
            Windows(stockid & "©u³ø.xlsx").Close

2. ¦³¥t¦s·sÀɪºµ{¦¡¦p¤U, ¥­§¡¨Cµ§³£»Ýªá¶O1~2¤ÀÄÁ¤~¯à§¹¦¨
     ½Ð°Ýµ{¦¡½X¦³¤°»ò¦a¤è¥i¥H§ïµ½¶Ü¡H
     ÁÙ¬O³o¼Ë§ì¨ú¸ê®Æ¤Ñ¥Í´Nµù©w³t«×·|ÀHµÛ°O¾ÐÅéªÅ¶¡¦û¾Ú¦Ó³vº¥ÅܺC¡H
     ¦³½Ð¦U¦ì«e½ú¨ó§U
  1. Private Sub CommandButton1_Click()

  2.     Dim StartTime
  3.     StartTime = Timer
  4.     Application.ScreenUpdating = False

  5.     For i = 1 To 100
  6.         
  7.         Dim stockid
  8.         stockid = Range("A" & i).Value
  9.    
  10.     Application.Wait Now + TimeValue("00:00:01")

  11.        '²{ª÷¬y¶qªí©u³ø
  12.        With Sheets("CFSQ")
  13.            .Rows("1:64").ClearContents
  14.            With .QueryTables.Add(Connection:= _
  15.                "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range( _
  16.                "$A$1"))
  17.                .Name = "zc3_2002.djhtm"
  18.                .FieldNames = True
  19.                .RowNumbers = False
  20.                .FillAdjacentFormulas = False
  21.                .PreserveFormatting = True
  22.                .RefreshOnFileOpen = False
  23.                .BackgroundQuery = True
  24.                .RefreshStyle = xlInsertDeleteCells
  25.                .SavePassword = False
  26.                .SaveData = True
  27.                .AdjustColumnWidth = True
  28.                .RefreshPeriod = 0
  29.                .WebSelectionType = xlSpecifiedTables
  30.                .WebFormatting = xlWebFormattingNone
  31.                .WebTables = "3"
  32.                .WebPreFormattedTextToColumns = True
  33.                .WebConsecutiveDelimitersAsOne = True
  34.                .WebSingleBlockTextImport = False
  35.                .WebDisableDateRecognition = False
  36.                .WebDisableRedirections = False
  37.                .Refresh BackgroundQuery:=False
  38.            End With
  39.        End With
  40.       
  41.       '·l¯qªí©u³ø
  42.        With Sheets("ISQ")
  43.            .Rows("1:64").ClearContents
  44.            With .QueryTables.Add(Connection:= _
  45.                "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range( _
  46.                "$A$1"))
  47.                .Name = "zcq_2002.asp"
  48.                .FieldNames = True
  49.                .RowNumbers = False
  50.                .FillAdjacentFormulas = False
  51.                .PreserveFormatting = True
  52.                .RefreshOnFileOpen = False
  53.                .BackgroundQuery = True
  54.                .RefreshStyle = xlInsertDeleteCells
  55.                .SavePassword = False
  56.                .SaveData = True
  57.                .AdjustColumnWidth = True
  58.                .RefreshPeriod = 0
  59.                .WebSelectionType = xlSpecifiedTables
  60.                .WebFormatting = xlWebFormattingNone
  61.                .WebTables = "3"
  62.                .WebPreFormattedTextToColumns = True
  63.                .WebConsecutiveDelimitersAsOne = True
  64.                .WebSingleBlockTextImport = False
  65.                .WebDisableDateRecognition = False
  66.                .WebDisableRedirections = False
  67.                .Refresh BackgroundQuery:=False
  68.            End With
  69.        End With
  70.       
  71.       '¸ê²£­t¶Åªí©u³ø
  72.        With Sheets("BSQ")
  73.            .Rows("1:64").ClearContents
  74.            With .QueryTables.Add(Connection:= _
  75.                "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:= _
  76.                .Range("$A$1"))
  77.                .Name = "zcpa_2002.asp"
  78.                .FieldNames = True
  79.                .RowNumbers = False
  80.                .FillAdjacentFormulas = False
  81.                .PreserveFormatting = True
  82.                .RefreshOnFileOpen = False
  83.                .BackgroundQuery = True
  84.                .RefreshStyle = xlInsertDeleteCells
  85.                .SavePassword = False
  86.                .SaveData = True
  87.                .AdjustColumnWidth = True
  88.                .RefreshPeriod = 0
  89.                .WebSelectionType = xlSpecifiedTables
  90.                .WebFormatting = xlWebFormattingNone
  91.                .WebTables = """oMainTable"""
  92.                .WebPreFormattedTextToColumns = True
  93.                .WebConsecutiveDelimitersAsOne = True
  94.                .WebSingleBlockTextImport = False
  95.                .WebDisableDateRecognition = False
  96.                .WebDisableRedirections = False
  97.                .Refresh BackgroundQuery:=False
  98.            End With
  99.        End With
  100.       
  101.             Application.DisplayAlerts = False '¦sÀɮɪ½±µÂл\­ì¦³ÀÉ®×
  102.       
  103.         '¥t¦s·sÀÉ
  104.             Sheets(Array("CFSQ", "ISQ", "BSQ")).Copy
  105.             ActiveWorkbook.SaveAs Filename:= _
  106.               "C:\Users\user\Documents\KT\§ë¸ê²z°]\Excel¤ÀªR¼Ò²Õ\" & stockid & "©u³ø.xlsx", FileFormat:= _
  107.                xlOpenXMLWorkbook, CreateBackup:=False
  108.                        
  109.             Application.DisplayAlerts = True
  110.             Windows(stockid & "©u³ø.xlsx").Close
  111.                
  112.     Next i

  113.    Application.ScreenUpdating = True
  114.    EndTime = Timer
  115.    MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
  116.       
  117.    
  118. End Sub
½Æ»s¥N½X

¦^´_ 2# GBKEE

¦hÁÂGBKEEª©¥D¦^´_
§Úªºµ{¦¡©ñ¦bªþ¥ó¤¤

½Ð°Ý±z¦^ÂЪº¤º®e¸Ó«ç»ò¨Ï¥Î...
§ÚÁÙ¤£·|¨Ï¥Îmodule
ª½±µ©ñ¨ì¤@­Ó·sªºÀɮפ¤°õ¦æ¤]µo¥Í°ÝÃD
¤£ª¾¹D¸Ó¦p¦ó¨Ï¥Î¥¦
«Ü©êºp³y¦¨±zªº§xÂZ~

VBA´ú¸Õ±M¥Î.zip (289.89 KB)

TOP

¦^´_ 4# GBKEE

GBKEEª©¥D±z¦n
§Ú¥[¤J±z­×§ïªºµ{¦¡¡A¸Ô¦pªþ¥ó
´ú¸Õ¤§«áµo²{´X­Ó°ÝÃD

1. ©|¥¼©I¥sDelete_QueryTables«e¡A³t«×®t²§¬Æ¤j
¤£¥t¦s·sÀÉ¡G99µ§¸ê®Æ¦@112¬í
¥t¦s·sÀÉ¡G²Ä1µ§´Nªá¤F121¬í...
¥i¨£©ì²Ö³t«×¬O¥t¦s·sÀɪº­ì¦]¡A½Ð°Ý¦³¦ó¸Ñ¨M¤§¹D¡H

2. ©I¥sDelete_QueryTables¡Aµo¥Í¿ù»~1004
¿ù»~¤º®e¦p¤U¹Ï

§Úµo²{¿ù»~¤º®e¬OQ.nameªº¦a¤è¦¨¬°"zc3_2002.djhtm_231"
¤£À´¬°¦ó«á­±·|¦h¤F_231³o´X­Ó¦r

VBA´ú¸Õ±M¥Î.zip (270.05 KB)
  1. Private Sub CommandButton1_Click()

  2.     Dim StartTime
  3.     StartTime = Timer
  4.     Application.ScreenUpdating = False
  5.     LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ

  6.     For i = 2 To LastRow
  7.         
  8.         Dim stockid
  9.         stockid = Range("A" & i).Value
  10.    
  11.     Application.Wait Now + TimeValue("00:00:01")

  12.        With Sheets("CFSQ")
  13.            '.Rows("1:64").ClearContents
  14.            '******************************
  15.             If .QueryTables.Count > 1 Then
  16.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  17.             Else  '¨S¦³QueryTable®É·s¼W
  18.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  19.             End If
  20.             With .QueryTables(1)  '¤£¦A·s¼W
  21.                 .AdjustColumnWidth = True
  22.                 .RefreshPeriod = 0
  23.                 .WebSelectionType = xlSpecifiedTables
  24.                 .WebFormatting = xlWebFormattingNone
  25.                 .WebTables = "3"
  26.                 .WebPreFormattedTextToColumns = True
  27.                 .WebConsecutiveDelimitersAsOne = True
  28.                 .Refresh BackgroundQuery:=False
  29.             End With
  30.             '******************************
  31.        End With
  32.       
  33.        With Sheets("ISQ")
  34.            '.Rows("1:64").ClearContents
  35.            '******************************
  36.             If .QueryTables.Count > 1 Then
  37.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
  38.             Else  '¨S¦³QueryTable®É·s¼W
  39.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  40.             End If
  41.             With .QueryTables(1)  '¤£¦A·s¼W
  42.                 .AdjustColumnWidth = True
  43.                 .RefreshPeriod = 0
  44.                 .WebSelectionType = xlSpecifiedTables
  45.                 .WebFormatting = xlWebFormattingNone
  46.                 .WebTables = "3"
  47.                 .WebPreFormattedTextToColumns = True
  48.                 .WebConsecutiveDelimitersAsOne = True
  49.                 .Refresh BackgroundQuery:=False
  50.             End With
  51.             '******************************
  52.        End With
  53.       
  54.        With Sheets("BSQ")
  55.            '.Rows("1:64").ClearContents
  56.            '******************************
  57.             If .QueryTables.Count > 1 Then
  58.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
  59.             Else  '¨S¦³QueryTable®É·s¼W
  60.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  61.             End If
  62.             With .QueryTables(1)  '¤£¦A·s¼W
  63.                 .AdjustColumnWidth = True
  64.                 .RefreshPeriod = 0
  65.                 .WebSelectionType = xlSpecifiedTables
  66.                 .WebFormatting = xlWebFormattingNone
  67.                 .WebTables = "3"
  68.                 .WebPreFormattedTextToColumns = True
  69.                 .WebConsecutiveDelimitersAsOne = True
  70.                 .Refresh BackgroundQuery:=False
  71.             End With
  72.             '******************************
  73.        End With
  74.       
  75.             Application.DisplayAlerts = False '¦sÀɮɪ½±µÂл\­ì¦³ÀÉ®×
  76.       
  77.             Sheets(Array("CFSQ", "ISQ", "BSQ")).Copy
  78.             ActiveWorkbook.SaveAs Filename:= _
  79.               "C:\Users\user\Desktop\Test\" & stockid & "©u³ø.xlsx", FileFormat:= _
  80.                xlOpenXMLWorkbook, CreateBackup:=False
  81.             Windows(stockid & "©u³ø.xlsx").Close
  82.                        
  83.             Application.DisplayAlerts = True

  84.        DELETE_QueryTables
  85.       
  86.     Next i

  87.    Application.ScreenUpdating = True
  88.    EndTime = Timer
  89.    MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
  90.       
  91.    
  92. End Sub
½Æ»s¥N½X
3. µ{¦¡½X¥[¤J¤§«á¡ABSQ³o­Ósheet¤º®e·|Åܦ¨ªÅ¥Õ
¥t¦s·sÀɮɡA¦³ªºÀɮצ³¤º®e¡A¦³ªºÀɮרS¤º®e¡A³o¬O¤°»ò­ì¦]³y¦¨ªº¡H

4. Delete_Querytables¦b¨C¤@¦¸°j°é°õ¦æ§¹²¦«á©I¥s¹ï¶Ü¡H

ÁÂÁª©¥D¦^ÂÐ~

TOP

³ø§iGBKEEª©¥D
¤]³\¥i¯à¬O§Úªº¹q¸£Àô¹Ò°ÝÃD³y¦¨³t«×ÅܺC....

¨º½Ð±Ð°ÝÃD2, 3ªº°ÝÃDªº­ì¦]¬°¦ó¡H
2.©I¥sDelete_Querytables®É¡Aµo¥Í1004¿ù»~
3.BSQ¤u§@ªíªÅ¥Õ°ÝÃD

ÁÂÁ±z~

TOP

¦^³øGBKEEª©¥D
ªÅ¥Õ¸ê®Æªººô­¶§Ú³£¦³½T»{¹L¡A¹ê»Ú¤W³£¦³¸ê®Æ
¥Ø«e¼È¥¼¥X²{   ­Y¦³¨ä¥L°ÝÃD¦A¸ò±z½Ð±Ð
ÁÂÁÂ

³t«×ªº°ÝÃD§Ú¦A§ä§ä¬Ý­ì¦]
¤W­Ó¬P´Á¤@¶}©l¼g¥X¨Óªº®É­Ô«Ü§Ö¡A¤@¤ÀÄÁ¬ù¦s10­ÓÀÉ¡AÀHÀÉ®×¼W¥[¦Ó®É¶¡¼É¼W
¤£ª¾¬°¦ó²{¦b¨C¦¸°õ¦æ³£­n1~2¤ÀÄÁ
¦³¥i¯à¬OµêÀÀ°O¾ÐÅé¨S³QÄÀ©ñ¶Ü
¦n©Ç

TOP

³ø§i¤@¤Uµ²ªG
¬Q¤Ñ§â¹q¸£ÁÙ­ì¨ì«e¤@¦¸³Æ¥÷
³t«×´N«ì´_¥¿±`¤F
ÁÂÁÂGBKEEª©¥D~~

TOP

¦^´_ 10# bulletin

½Ð±ÐGBKEEª©¥D
§Úµo²{°õ¦æ®É
¨C100~200µ§´N·|µo¥Í1004¿ù»~
³o¬O¦]¬°¥Î¨ì¤j¶qªºCOPY  ¾É­P°O¾ÐÅé¥X¿ù¶Ü¡H

±Nµ{¦¡§ï¼g¡A±N¸ê®Æ§ì¨ú¨ì¦W¬°tempªº¤u§@ªí¡A¨Ì§Ç¥t¦s¨ì·sÀÉ
¬O§_¥i¥H§ïµ½¡H

©Î¬O¦³¥i¯à¬O¨ä¥L­ì¦]©Ò³y¦¨¡H
  1. Private Sub CommandButton1_Click()

  2.     Dim StartTime, LastRow
  3.     StartTime = Timer
  4.     DELETE_QueryTables
  5.     Application.ScreenUpdating = False
  6.     LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ


  7.     For i = 2 To LastRow
  8.         
  9.         Dim stockid
  10.         stockid = Range("A" & i).Value
  11.    
  12.     Application.Wait Now + TimeValue("00:00:01")

  13.        With Sheets("CFSQ")
  14.            .Rows("1:64").ClearContents
  15.            
  16.            '******************************
  17.             If .QueryTables.Count > 1 Then
  18.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  19.             Else  '¨S¦³QueryTable®É·s¼W
  20.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  21.             End If
  22.             With .QueryTables(1)  '¤£¦A·s¼W
  23.                 .AdjustColumnWidth = True
  24.                 .RefreshPeriod = 0
  25.                 .WebSelectionType = xlSpecifiedTables
  26.                 .WebFormatting = xlWebFormattingNone
  27.                 .WebTables = "3"
  28.                 .WebPreFormattedTextToColumns = True
  29.                 .WebConsecutiveDelimitersAsOne = True
  30.                 .Refresh BackgroundQuery:=False
  31.             End With
  32.             '******************************
  33.             
  34.        End With
  35.       
  36.        With Sheets("ISQ")
  37.            .Rows("1:64").ClearContents
  38.            
  39.            '******************************
  40.             If .QueryTables.Count > 1 Then
  41.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
  42.             Else  '¨S¦³QueryTable®É·s¼W
  43.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  44.             End If
  45.             With .QueryTables(1)  '¤£¦A·s¼W
  46.                 .AdjustColumnWidth = True
  47.                 .RefreshPeriod = 0
  48.                 .WebSelectionType = xlSpecifiedTables
  49.                 .WebFormatting = xlWebFormattingNone
  50.                 .WebTables = "3"
  51.                 .WebPreFormattedTextToColumns = True
  52.                 .WebConsecutiveDelimitersAsOne = True
  53.                 .Refresh BackgroundQuery:=False
  54.             End With
  55.             '******************************
  56.             
  57.        End With
  58.       
  59.        With Sheets("BSQ")
  60.            .Rows("1:64").ClearContents
  61.            
  62.            '******************************
  63.             If .QueryTables.Count > 1 Then
  64.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
  65.             Else  '¨S¦³QueryTable®É·s¼W
  66.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  67.             End If
  68.             With .QueryTables(1)  '¤£¦A·s¼W
  69.                 .AdjustColumnWidth = True
  70.                 .RefreshPeriod = 0
  71.                 .WebSelectionType = xlSpecifiedTables
  72.                 .WebFormatting = xlWebFormattingNone
  73.                 .WebTables = "3"
  74.                 .WebPreFormattedTextToColumns = True
  75.                 .WebConsecutiveDelimitersAsOne = True
  76.                 .Refresh BackgroundQuery:=False
  77.             End With
  78.             '******************************
  79.            
  80.        End With
  81.       
  82.             Application.DisplayAlerts = False '¦sÀɮɪ½±µÂл\­ì¦³ÀÉ®×
  83.       
  84.             Sheets(Array("CFSQ", "ISQ", "BSQ")).Copy
  85.             ActiveWorkbook.SaveAs Filename:= _
  86.               "C:\Users\KT\Desktop\Test\" & stockid & "©u³ø.xlsx", FileFormat:= _
  87.                xlOpenXMLWorkbook, CreateBackup:=False
  88.             Windows(stockid & "©u³ø.xlsx").Close
  89.                        
  90.             Application.DisplayAlerts = True
  91.       
  92.     Next i

  93.    Application.ScreenUpdating = True
  94.    EndTime = Timer
  95.    MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
  96.       
  97.    
  98. End Sub
½Æ»s¥N½X

TOP

¦^´_ 12# Hsieh

§Ú¤]·Q¹L¬O¬y¶qºÞ¨îªº°ÝÃD
¦hÁ»¡©ú

µL½×¦p¦ó¨Ó§ï¼g¦¨temp¦n¤F
·í°µ½m²ß¤]¦n
¨ì®É¦A½Ð¦U¦ì«e½ú«ü±Ð

TOP

¦^´_ 13# bulletin

¦U¦ì«e½ú
§Ú¤S­×§ï¤F¤@­Ó¡A³o¦¸ª½±µ¥ý¶}±Ò·sªº¬¡­¶Ã¯
¨Ã±N¸ê®Æª½±µ¦s¤J¬¡­¶Ã¯¤¤

1. ¥ý§ì¸ê®Æ¡A¦A½Æ»s¥t¦s·sÀÉ
100µ§ --> 102¬í
200µ§ --> 210¬í

2. ¥ý«Ø¥ß·sÀɦA§ì¸ê®Æ¦sÀÉ
100µ§ --> 100¬í
200µ§ --> 206¬í

¦ü¥G¤Ö¤F½Æ»s¥t¦s³t«×µyµy§Ö¤@ÂI
¦ý¬O¦Ò¶qºô¸ôí©w©Ê¥H¤Îºô¯¸¦s¨úªº°ÝÃD
À³¸Ó¬O¨S¦³®t

¦¹¥~¤´µM¦³¿ù»~1004ªº°ÝÃD, ©Ò¥H¨S¿ìªk´ú¸Õ500µ§¥H¤W©Î¬O©Ò¦³¤W¥«Âd¤½¥q1400Àɪº³t«×...

¿ù»~·|µo¥Í¦b½Æ»sºô­¶¸ê®Æ¡A¦s¨ì¤u§@ªí¤¤®É
¤£¤@©w·|¦b¦ó®Éµo¥Í
¦ý­ì«h¤W¤´¯d¦b100~200µ§¤§¶¡·|µo¥Í
§Ú¦A§â©µ¿ð®É¶¡©Ôªø¡A¬Ý¯à¤£¯àÁקK¿ù»~1004
ÁÂÁ¦U¦ì«e½ú«ü±Ð~
  1. Sub stest()

  2.     Dim StartTime, LastRow
  3.     Dim wbnew As Workbook
  4.    
  5.     DELETE_QueryTables
  6.    
  7.     StartTime = Timer
  8.     LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ

  9.     Application.ScreenUpdating = False
  10.    
  11.     For i = 2 To 101
  12.         
  13.         Dim stockid
  14.         stockid = Range("A" & i).Value
  15.    
  16.         Application.DisplayAlerts = False
  17.         Application.Wait Now + TimeValue("00:00:01")
  18.         
  19.         
  20.         Set wbnew = Workbooks.Add() '·s¼W¬¡­¶Ã¯
  21.         wbnew.SaveAs Filename:="C:\Users\KT\Desktop\Test2\" & stockid & ".xlsx"  '¥t¦s·sÀÉ

  22.         With wbnew.Sheets(1) 'CFSQ
  23.            '.Rows("1:64").ClearContents
  24.            
  25.            '******************************
  26.             If .QueryTables.Count > 1 Then
  27.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
  28.             Else  '¨S¦³QueryTable®É·s¼W
  29.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
  30.             End If
  31.             With .QueryTables(1)  '¤£¦A·s¼W
  32.                 .AdjustColumnWidth = True
  33.                 .RefreshPeriod = 0
  34.                 .WebSelectionType = xlSpecifiedTables
  35.                 .WebFormatting = xlWebFormattingNone
  36.                 .WebTables = "3"
  37.                 .WebPreFormattedTextToColumns = True
  38.                 .WebConsecutiveDelimitersAsOne = True
  39.                 .Refresh BackgroundQuery:=False
  40.             End With
  41.             '******************************
  42.             
  43.        End With
  44.       
  45.     With Sheets(2)
  46.            '.Rows("1:64").ClearContents
  47.            
  48.            '******************************
  49.             If .QueryTables.Count > 1 Then
  50.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
  51.             Else  '¨S¦³QueryTable®É·s¼W
  52.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  53.             End If
  54.             With .QueryTables(1)  '¤£¦A·s¼W
  55.                 .AdjustColumnWidth = True
  56.                 .RefreshPeriod = 0
  57.                 .WebSelectionType = xlSpecifiedTables
  58.                 .WebFormatting = xlWebFormattingNone
  59.                 .WebTables = "3"
  60.                 .WebPreFormattedTextToColumns = True
  61.                 .WebConsecutiveDelimitersAsOne = True
  62.                 .Refresh BackgroundQuery:=False
  63.             End With
  64.             '******************************
  65.             
  66.        End With
  67.       
  68.        With Sheets(2)
  69.            '.Rows("1:64").ClearContents
  70.            
  71.            '******************************
  72.             If .QueryTables.Count > 1 Then
  73.                 .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
  74.             Else  '¨S¦³QueryTable®É·s¼W
  75.                 .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
  76.             End If
  77.             With .QueryTables(1)  '¤£¦A·s¼W
  78.                 .AdjustColumnWidth = True
  79.                 .RefreshPeriod = 0
  80.                 .WebSelectionType = xlSpecifiedTables
  81.                 .WebFormatting = xlWebFormattingNone
  82.                 .WebTables = "3"
  83.                 .WebPreFormattedTextToColumns = True
  84.                 .WebConsecutiveDelimitersAsOne = True
  85.                 .Refresh BackgroundQuery:=False
  86.             End With
  87.             '******************************
  88.            
  89.        End With
  90.       
  91.        Windows(stockid & ".xlsx").Close savechanges:=True
  92.        Application.DisplayAlerts = True

  93.     Next i
  94.    
  95.    
  96.    Application.ScreenUpdating = True
  97.    EndTime = Timer
  98.    MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
  99.       
  100.    
  101. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD