- ©«¤l
- 27
- ¥DÃD
- 7
- ºëµØ
- 0
- ¿n¤À
- 38
- ÂI¦W
- 0
- §@·~¨t²Î
- Win 7
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-9-19
- ³Ì«áµn¿ý
- 2014-2-18
|
¦^´_ 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)
- Private Sub CommandButton1_Click()
- Dim StartTime
- StartTime = Timer
- Application.ScreenUpdating = False
- LastRow = Sheets("sheet1").Range("A2").End(xlDown).Row '§ä¥X³Ì«á¤@µ§¸ê®Æ
- For i = 2 To LastRow
-
- Dim stockid
- stockid = Range("A" & i).Value
-
- Application.Wait Now + TimeValue("00:00:01")
- With Sheets("CFSQ")
- '.Rows("1:64").ClearContents
- '******************************
- If .QueryTables.Count > 1 Then
- .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm"
- Else '¨S¦³QueryTable®É·s¼W
- .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zc3/zc3_" & stockid & ".djhtm", Destination:=.Range("$A$1")
- End If
- With .QueryTables(1) '¤£¦A·s¼W
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "3"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .Refresh BackgroundQuery:=False
- End With
- '******************************
- End With
-
- With Sheets("ISQ")
- '.Rows("1:64").ClearContents
- '******************************
- If .QueryTables.Count > 1 Then
- .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm"
- Else '¨S¦³QueryTable®É·s¼W
- .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcq/zcq_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
- End If
- With .QueryTables(1) '¤£¦A·s¼W
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "3"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .Refresh BackgroundQuery:=False
- End With
- '******************************
- End With
-
- With Sheets("BSQ")
- '.Rows("1:64").ClearContents
- '******************************
- If .QueryTables.Count > 1 Then
- .QueryTables(1).Connection = "URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm"
- Else '¨S¦³QueryTable®É·s¼W
- .QueryTables.Add Connection:="URL;http://dj.mybank.com.tw/z/zc/zcp/zcpa/zcpa_" & stockid & ".asp.htm", Destination:=.Range("$A$1")
- End If
- With .QueryTables(1) '¤£¦A·s¼W
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = "3"
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .Refresh BackgroundQuery:=False
- End With
- '******************************
- End With
-
- Application.DisplayAlerts = False '¦sÀɮɪ½±µÂл\즳ÀÉ®×
-
- Sheets(Array("CFSQ", "ISQ", "BSQ")).Copy
- ActiveWorkbook.SaveAs Filename:= _
- "C:\Users\user\Desktop\Test\" & stockid & "©u³ø.xlsx", FileFormat:= _
- xlOpenXMLWorkbook, CreateBackup:=False
- Windows(stockid & "©u³ø.xlsx").Close
-
- Application.DisplayAlerts = True
-
- DELETE_QueryTables
-
- Next i
- Application.ScreenUpdating = True
- EndTime = Timer
- MsgBox "¥»¦¸¤U¸ü¦@ªá¶O¡G" & EndTime - StartTime & "¬í"
-
-
- 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¦^ÂÐ~ |
|