¥Î°j°é§ì¸ê®Æ¶V¶]¶VºC¡A¸Ó¦p¦óÄÀ©ñ°O¾ÐÅé?
- ©«¤l
- 49
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 154
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-6-16
- ³Ì«áµn¿ý
- 2024-8-5
|
¥Î°j°é§ì¸ê®Æ¶V¶]¶VºC¡A¸Ó¦p¦óÄÀ©ñ°O¾ÐÅé?
¦U¦ì«e½ú¤j®a¦n,
§Ú¦³Óµ{¦¡¨Ï¥Î°j°é¤Îquerytable.addªº¤è¦¡§ì¨ú¥~³¡¸ê®Æ(§ì§¹·|°õ¦æquerytable.delete)
¨Ã¦b¶×¤J¸ê®Æ«á¥Îworksheets.copyªº¤è¦¡¥t¦s¡A
¦¹®Éµ{¦¡·|¦Û°Ê·s¼W¤@Ó¬¡¶Ã¯¡A«Ý¦sÀÉ«á¦A±N·s¼Wªº¬¡¶Ã¯Ãö³¬
¦ý§Úµo²{¦p¦¹¤@¨Ó¡A¦]¬°¨C¦¸copy¤u§@ªí®É³£·|·s¼W¤@Ó¬¡¶Ã¯
¦pªG§Úªº°j°é¤@¦@n§ì¦n´X¦Ê¦¸ªº¸ê®Æ
¨º´N·|¼W¥[¦n´X¦ÊÓ¬¡¶Ã¯
ÁöµM¤§«á·|Ãö³¬¡A¦ý¤£¾å±o°O¾ÐÅ馳¨S¦³ÄÀ©ñ±¼¡A¦]¬°¬¡¶Ã¯ªº½s¸¹·|¤@ª½¼W¥[¤W¥h
¦Óµ{¦¡¶]ªº³t«×¤]¶V¨Ó¶VºC....@@"
¥i¥H½Ð¦U¦ì«e½úÀ°¦£¸Ñµª¤@¤U¶Ü? ÁÂÁ |
|
|
|
|
|
|
- ©«¤l
- 49
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 154
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-6-16
- ³Ì«áµn¿ý
- 2024-8-5
|
¦^´_ 14# GBKEE
¹ê»Ú´ú¸ÕG¤j©Ò´£¨Ñªºµ{¦¡¡A½T¹ê¤ñ¤§«eªº¨ºÓÁÙn§Ö«Ü¦h
¥J²Ó¤ñ¹ï«á¡A§Úµo²{¥Dnªº°ÝÃD¬O¦b©ó½Õ¾ã®æ¦¡³o³¡¤À
¦]¬°³o¨Ç¸ê®Æ§Ú·|¦A¶×¤J¨ìmysql·í¤¤¡A©Ò¥H¸ê®Æ®æ¦¡¤£¯à¥X¿ù
©Ò¥H¦b³Ì¤@¶}©l§Ú©Ò´£¨Ñªºµ{¦¡¤¤¡A¦bsub ½Õ¾ã®æ¦¡()ªº³Ì«á¡A§Ú¦³¦A¥[¤W¤@¬q«ü¥O
cells.NumberFormatLocal = "G/³q¥Î®æ¦¡"
¦Ó³o¬q«ü¥O¬OG¤j©Ò´£¨Ñªºµ{¦¡½X¤¤©Ò¨S¦³ªº
¥Ø«e±À´ú´N¬O¦]¬°³o¬q±Ôz¡A¾ÉP¾ãÓµ{¦¡³t«×°¤F¤U¨Ó
¥H¤Îµ{¦¡°õ¦æ¹Lµ{¡AEXCEL©Ò¥e¥Îªº°O¾ÐÅ餣Â_Ãk°ª
·PÁÂG¤jªº«üÂI¡A¨ü±Ð¤F¡I |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-6-25 13:39 ½s¿è
¦^´_ 13# sasho
§A쥻ªº Sub °õ¦æ(),¦b§ÚªºPC¨S¦³§A©Ò»¡ªº¶V¨Ó¶VºCªº±¡§Î.³t«×»PMain() ªº°O¿ýÀÉ®t¤£¦h.
¾ã²z¤@¤U,ªþ¤W Sub Main() ªº°O¿ýÀÉ
Ex.rar (10.87 KB)
- Option Explicit
- Dim IE As Object, Query_Sh As Worksheet, CsvPath As String, SaveDate As String
- Dim t As Date, StartTime As Date, °O¿ýÀÉ As String, stockid As Range, spListCount As Integer
- Sub Main()
- Dim i As Integer
- t = Time
- StartTime = Time
- CsvPath = "D:\TSE\"
- ¥Ø¿ý CsvPath
- °O¿ýÀÉ = CsvPath & "Main_Record.TXT"
- If Dir(°O¿ýÀÉ) <> "" Then Kill °O¿ýÀÉ
- ¼È¦s¶ "temp"
- xRecond 0, "µ{¦¡¶}©l°õ¦æ" & vbCrLf
- Set stockid = Sheets("¤u§@ªí1").Range("A2")
- stockid.Parent.Activate
- Do While stockid <> ""
- Application.ScreenUpdating = True
- stockid.Select
- Application.ScreenUpdating = False
- StartTime = Time
- spListCount = ¸ê®Æ¶¼Æ
- If spListCount > 0 Then
- i = i + 1
- xRecond i, stockid & vbTab & "¸ê®Æ¶×¤J"
- ¸ê®Æ¶×¤J
- ¾ã²z
- ¦sÀÉ
- xRecond i, stockid.Value & vbTab & "¦sÀɧ¹²¦ " & Format(Time - StartTime, "¦@SS¬í") & vbCrLf
- End If
- Set stockid = stockid.Offset(1)
- Loop
- IE.Quit
- Application.DisplayAlerts = False
- Query_Sh.Delete
- Application.DisplayAlerts = True
- Workbooks.Open °O¿ýÀÉ
- MsgBox "¦@¦s ""(" & i & ") csvÀɧ¹²¦" & vbTab & "¶O®É " & Format(Time - t, "nn¤Àss¬í")
- End Sub
- Private Sub ¼È¦s¶(temp As String)
- On Error Resume Next
- Set Query_Sh = Sheets(temp)
- If Err.Number = 9 Then
- Sheets.Add(, Sheets(1)).Name = temp
- Set Query_Sh = Sheets(temp)
- End If
- End Sub
- Private Sub ¸ê®Æ¶×¤J()
- Dim strURL As String
- strURL = "URL;" & "http://bsr.twse.com.tw/bshtm/bsContent.aspx?StartNumber=" & stockid & "&FocusIndex=All_" & spListCount
- With Query_Sh
- .UsedRange.Clear
- With .QueryTables.Add(strURL, Query_Sh.[a1])
- .WebFormatting = xlWebFormattingNone
- .WebSelectionType = xlSpecifiedTables
- .WebTables = "5,table2"
- .Refresh 0
- .Delete
- End With
- End With
- End Sub
- Private Sub ¾ã²z()
- Dim i As Integer
- With Sheets("temp")
- SaveDate = Format(.Range("B1"), "YYYYMMDD")
- With .UsedRange.Range("A:A")
- .SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
- .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
- End With
- .UsedRange.Columns("F:J").Cut
- .Range("A" & .Rows.Count).End(xlUp).Offset(1).Insert Shift:=xlDown
- .UsedRange.Sort Key1:=.Range("A1"), Order1:=xlAscending, Header:=xlNo
- .UsedRange.Columns("B:B").Insert Shift:=xlToRight
- .UsedRange.Columns(1) = SaveDate
- .UsedRange.Columns(2) = stockid
- For i = 1 To .UsedRange.Rows.Count
- .Cells(i, 3) = Left(.Cells(i, 3), 4)
- .Cells(i, 5) = .Cells(i, 5).Value / 1000
- .Cells(i, 6) = .Cells(i, 6).Value / 1000
- Next
- End With
- End Sub
- Private Sub ¥Ø¿ý(xPath As String)
- Dim SP As Variant, P As String, i As Integer
- SP = Split(xPath, "\")
- P = SP(0)
- With CreateObject("Scripting.FileSystemObject")
- For i = 1 To UBound(SP)
- P = P & "\" & SP(i)
- If .FolderExists(P) = False Then .CreateFolder (P)
- Next
- End With
- End Sub
- Private Sub ¦sÀÉ()
- Dim CSVfolder As String, CSVfile As String
- CSVfolder = CsvPath & SaveDate & "\"
- ¥Ø¿ý CSVfolder
- CSVfile = CSVfolder & stockid & "_" & SaveDate & ".csv"
- If Dir(CSVfile) <> "" Then Kill CSVfile
- Query_Sh.Copy
- With ActiveWorkbook
- .SaveAs Filename:=CSVfile, FileFormat:=xlCSV
- .Close 0
- End With
- End Sub
- Private Sub xRecond(i As Integer, xSub As String)
- Dim S As String
- S = Time & vbTab & Format(Time - t, " ²Änn¤Àss¬í") & vbTab & " ²Ä " & i & " ÓCsvÀÉ " & xSub
- Close #1
- Open °O¿ýÀÉ For Append As #1
- Print #1, S
- Close #1
- Application.StatusBar = S
- End Sub
- Private Function ¸ê®Æ¶¼Æ() As Integer '¨ú±o¶¼Æ
- If IE Is Nothing Then
- Set IE = CreateObject("InternetExplorer.Application")
- IE.Navigate "http://bsr.twse.com.tw/bshtm/bsMenu.aspx"
- IE.Visible = True '¥i¤£Åã¥Ü
- End If
- With IE
- Do: Loop While .Busy Or IE.ReadyState <> 4
- With .document
- .getElementByID("txtTASKNO").Value = stockid
- .getElementByID("btnOK").Click
- Do: Loop While IE.Busy Or IE.ReadyState <> 4 Or .getElementByID("sp_ListCount") Is Nothing
- ¸ê®Æ¶¼Æ = Val(.getElementByID("sp_ListCount").innertext)
- End With
- End With
- End Function
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 49
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 154
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-6-16
- ³Ì«áµn¿ý
- 2024-8-5
|
¦^´_ 12# GBKEE
·PÁÂGª©¤jªºÀ°¦£¡A¦]¬°§ÚµLªk¤W¶ÇÀɮסA©Ò¥H§âÀɮשñ¦b¦p¤Uªºdropboxªººô§}
¥t¥~¡A³Ìªñ´X¤Ñ´ú¸Õªºµ²ªG¡Aµo²{°ÝÃD¬O¥X¦b¨âÓ³¡¤À
¤@Ó¬O¶×¤Jºô¶¸ê®Æ¡A¥t¤@Ó¬O±N¶×¤J¸ê®Æ¥t¦s¦¨csvÀÉ
®Ú¾Ú°O¿ýªº¸ê®Æ¡A³o¨âӰʧ@³£·|ÀHµÛ°j°é¶V¶]¶V¦h¦Ó¶V¨Ó¶VºC
ÁÙ½ÐGª©¤j«üÂI¤@¤U¡AÁÂÁÂ
https://www.dropbox.com/s/n0ycnc7q4gqtbrb/%E6%8A%93%E5%8F%96%E4%B8%8A%E5%B8%82%E8%B3%87%E6%96%99.xls |
|
|
|
|
|
|
- ©«¤l
- 49
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 154
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-6-16
- ³Ì«áµn¿ý
- 2024-8-5
|
¦^´_ 10# GBKEE
·PÁÂG¤jªº¤À¨É
¤£¹L¤p§Ì§ÚÁÙ¬O¤£¤Ó¤F¸Ñ¡A¬°¤°»ò¦bEXCEL¤¤¥Î°j°é¶×¤J¸ê®Æ·|¶V¶×¶VºC....
§Ú¨Ï¥Îªº¬Owin 7¡B64¦ì¤¸¡B6G°O¾ÐÅé
¥±`¦³²M°£¨t²Î©U§£ªº²ßºD¡A¥B¦b°õ¦æµ{¦¡®É¡A¤£½×CPU©Î¬O°O¾ÐÅé³£Åã¥Ü©|¦³¦h¾lªº¸ê·½(±q¤u§@ºÞ²zûÆ[¹î)
ªp¥B¡A¦pªG¬O¦]¬°¨t²Î¸ê·½¤£¨¬©Ò¾ÉPªº°ÝÃD¡AÀ³¸Ó¤£·|¥X²{°õ¦æµ{¦¡ªì´Á³t«×¸û§Ö¡A¦Ó°õ¦æ¨ì«á±³t«×´N¾ãÓ©ì¤U¨Óªº±¡ªp¤~¬O
À³¸Ó¬O±qÀY¨ì§À³£«ÜºC¤~¬O
¤£¾å±o§Ú³o¼Ë±À½×¬O§_¥¿½T©O? |
|
|
|
|
|
|
- ©«¤l
- 49
- ¥DÃD
- 18
- ºëµØ
- 0
- ¿n¤À
- 154
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- XP
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-6-16
- ³Ì«áµn¿ý
- 2024-8-5
|
¦^´_ 8# stillfish00
§Ú¨Ï¥Îªº¬OEXCEL 2010¡A°õ¦æQueryTables.delete¨Ã¤£·|±N¶×¤J¸ê®Æ§R°£¡A¥u·|§â³s½u§R°£¦Ó¤w
¥t¥~¡A§Ú¦b¥t¦s¶×¤J¸ê®Æ«á¡A¤]·|¦b°õ¦æworksheets.cells.delete¡A©Ò¥H¸ê®Æ¬O¤£·|¦V¥k²Ö¿nªº
·PÁÂ |
|
|
|
|
|
|
- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-6-17 14:09 ½s¿è
¦^´_ 9# GBKEE
QueryTables.Delete ¥u·|§R°£³s½u©M©w¸qªº¦WºÙ¡A¤£·|§R°£¨ú±oªº¸ê®Æ
¦Ó¼Ó¥D¥Î°j°é°õ¦æ¦hµ§®É¸ê®Æ·|¤@ª½©¹¥k²Ö¿n¼W¥[
³o¤]³\¥i¥H§ïRefreshStyle¬°xlOverwriteCells¨Ó¨¾¤î(¹w³]¬OxlInsertDeleteCells)
¹³³o¼Ë- Sub Ex()
- Dim i As Integer, Rng As Range
- With ActiveSheet
- For i = 3 To 7 Step 2
- With .QueryTables.Add("URL;http://forum.twbts.com/thread-635-1-1.html", .Cells(1, 1))
- .WebSelectionType = xlSpecifiedTables
- .WebFormatting = xlWebFormattingNone
- .WebTables = i & ""
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
-
- .RefreshStyle = xlOverwriteCells
- .Refresh BackgroundQuery:=False
- Wb_Save .ResultRange, i
-
- .Delete
- End With
- Next
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|