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

[µo°Ý] ¤@­Ó¥ÎVBA±qºô­¶¨ú±o·Q­n¸ê®Æªº¼gªk~

¦^´_ 35# GBKEE

¤È¦w G¤j

§Aªº³o­ÓÂà½X¨t²Î

¦pªG¬O¦bQTªº¸Ü,¸Ó«ç»ò©I¥s?
ÁÂÁ±z^^¨¯­W¤F

¨Ò¦p(¥H¤U)
  1. Sub ¤U¸üCSV()
  2. Set book1 = ActiveSheet
  3. Set bookshow = book1.QueryTables _
  4.     .Add(Connection:="TEXT;https://smart.tdcc.com.tw/opendata/getOD.ashx?id=2-8", _
  5.         Destination:=book1.Range("a1"))
  6. With bookshow

  7.     .TextFileParseType = xlDelimited
  8.   .TextFileCommaDelimiter = True
  9.     .Refresh
  10. End With

  11. End Sub
½Æ»s¥N½X
VBA ±q0¶}©l
¥ý±q¾Ç·|¬ÝªºÀ´¶}©l
¥ý±q·|¦³°ò¥»­×§ï¯à¤O¶}©l
¤@¨B¤@¨B¾Ç²ß¤¤

TOP

¥»©«³Ì«á¥Ñ bioleon69 ©ó 2017-5-8 06:05 ½s¿è

¦^´_ 35# GBKEE


º}«G,¥Ø«e¦b¾ÇµÛ¥ÎXML°Õ
¨º­ÓÂà½Xªºº}«G,ÁöµM¤£¬O«ÜÀ´¼gªk
¤p§Ì¥u¯à¥ý§Û¤U¨Ó¦º­I®M¥Î
½×¾Â²×©ó¦n¤FXDD

·PÁÂGBK¤j!

TOP

¦^´_ 33# bioleon69
  1. Option Explicit
  2. Sub ´ú¸Õ()
  3.     Dim oXmlhttp As Object, oHtmldoc As Object, surl, E As Object
  4.     Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  5.     Set oHtmldoc = CreateObject("htmlfile")
  6.     surl = "http://mops.twse.com.tw/nas/t21/sii/t21sc03_106_3_0.html"
  7.     With oXmlhttp
  8.         .Open "Get", surl, False
  9.         .Send
  10.         'oHtmldoc.write .responseText
  11.         oHtmldoc.write BinToStr(.responseBody, "BIG5") 'ºô­¶½s½X "¤¤¤å"
  12.     End With
  13.     With oHtmldoc
  14.         Set E = .all.tags("TABLE")(3)
  15.     End With
  16.     Application.ScreenUpdating = False
  17.     Ex_°Æµ{¦¡ E
  18.     Application.ScreenUpdating = True
  19. End Sub
  20. Private Sub Ex_°Æµ{¦¡(A As Object)
  21.     Dim i As Integer, R As Integer, C As Integer
  22.     With ActiveSheet    '¥i«ü©w¤u§@ªí
  23.         .UsedRange.Clear
  24.         For R = 0 To A.Rows.Length - 1
  25.                 For C = 0 To A.Rows(R).Cells.Length - 1
  26.                     .Cells(R + 1, C + 1) = A.Rows(R).Cells(C).innertext
  27.                 Next
  28.         Next
  29.         With .UsedRange  ' CELL ¬°¾ã¤u§@ªíªºÀx¦s®æ ½d³ò¤j(¶O®É)
  30.            ' .UsedRange ¤u§@ªí¦³¨Ï¥Î¨ìªºªºÀx¦s®æ ½d³ò¤p(¬Ù®É)
  31.             .EntireRow.AutoFit
  32.             .EntireColumn.AutoFit
  33.         End With
  34.     End With
  35. End Sub
  36. Function BinToStr(arrBin, strChrs) As String
  37.     With CreateObject("ADODB.Stream")  '¤G¶i¦ì¤åÀÉ,¶Ç°e,Àx¦s
  38.         .Type = 2
  39.         .Open
  40.         .Writetext arrBin
  41.         .Position = 0
  42.         .Charset = strChrs   '«ü©w½s½X
  43.         BinToStr = .ReadText
  44.         .Close
  45.     End With
  46. End Function
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 33# bioleon69

¥i§ï¥Î·|¤J¥~³¡¸ê®Æ .QueryTables
  1. Option Explicit
  2. Sub Ex()
  3.     With ActiveSheet.QueryTables.Add(Connection:="URL;http://mops.twse.com.tw/nas/t21/sii/t21sc03_106_3_0.html", Destination:=Range("A1"))
  4.         .WebSelectionType = xlSpecifiedTables
  5.         .WebFormatting = xlWebFormattingNone
  6.         .WebTables = "4"
  7.         .RefreshStyle = xlOverwriteCells
  8.         .WebPreFormattedTextToColumns = True
  9.         .WebConsecutiveDelimitersAsOne = True
  10.         .WebSingleBlockTextImport = False
  11.         .WebDisableDateRecognition = False
  12.         .WebDisableRedirections = False
  13.         .Refresh BackgroundQuery:=False
  14.     End With
  15. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ bioleon69 ©ó 2017-5-3 06:35 ½s¿è

¨â­ÓºÃ°Ý
#¶Ã½X
#¥þ³¡ªí®æªº«ü©w¤èªk


http://mops.twse.com.tw/nas/t21/sii/t21sc03_106_3_0.html
¦pªG¬O³o­Óºô­¶
·|Åܳo¼Ë



¦pªG¬O­n§ì³oºô­¶ªº¥þ³¡ªí®æ¤º®e
«D³æ¤@«ü©wªí®æ

À³¸Ó«ç»ò­×§ï?
With oHtmldoc
        Set E = .all.tags("TABLE")(9)
End With

ÃöÁäÀ³¸Ó¬O³o¤@¦æ?«á­±¥´(0)·|¥X²{¿ù»~

¨D«ü¾É!·PÁÂ

TOP

¥»©«³Ì«á¥Ñ bioleon69 ©ó 2017-5-1 21:40 ½s¿è

¦^´_ 31# GBKEE


¤F¸Ñ
¹ï³o¨â­Óª«¥óÁÙ«Ü­¯¥Í
CreateObject("msxml2.xmlhttp")
CreateObject("htmlfile")
¥Ø«e¤]´X¥G³£¬O§Û¼gG¤j¯d¤Uªºµ{¦¡½X­×§ï¾Ç²ß
»°ºò¨Ó¾Ç²ß¬Ý¬Ý

THX G¤j!

TOP

¦^´_ 30# bioleon69
  1. ''CreateObject("InternetExplorer.Application") »Ýµ¥­Ôºô­¶¤U¸ü§¹²¦³t«×¸ûºC
  2. '°õ¦æ°j°éÅý¥¦¶]1500¦¸,¼K³t«×·|ºC³\¦h
  3. Option Explicit
  4. Sub ´ú¸Õ()
  5.     Dim oXmlhttp As Object, oHtmldoc As Object, surl, E As Object
  6.     Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  7.     Set oHtmldoc = CreateObject("htmlfile")
  8.     surl = "http://norway.twsthr.info/StockHolders.aspx?stock=2330"
  9.     With oXmlhttp
  10.         .Open "Get", surl, False
  11.         .Send
  12.         oHtmldoc.write .responseText
  13.     End With
  14.     With oHtmldoc
  15.         Set E = .all.tags("TABLE")(9)
  16.     End With
  17.     Application.ScreenUpdating = False
  18.     Ex_°Æµ{¦¡ E
  19.     Application.ScreenUpdating = True
  20. End Sub
  21. Private Sub Ex_°Æµ{¦¡(A As Object)
  22.     Dim i As Integer, R As Integer, C As Integer
  23.     With ActiveSheet    '¥i«ü©w¤u§@ªí
  24.         .UsedRange.Clear
  25.         For R = 0 To 2 * 5    'Ū¨ú5µ§¸ê®Æ ' Âù¼ÆªºA.Rows¬°ªÅ¥Õ¸ê®Æ
  26.             If R <= 1 Or R > 2 And R Mod 2 = 1 Then '­ç°£ Âù¼ÆªºA.Rows
  27.                 i = i + 1
  28.                 For C = 2 To A.Rows(R).Cells.Length - 1
  29.                     .Cells(i, C - 1) = A.Rows(R).Cells(C).innertext
  30.                 Next
  31.             End If
  32.         Next
  33.         With .UsedRange  ' CELL ¬°¾ã¤u§@ªíªºÀx¦s®æ ½d³ò¤j(¶O®É)
  34.            ' .UsedRange ¤u§@ªí¦³¨Ï¥Î¨ìªºªºÀx¦s®æ ½d³ò¤p(¬Ù®É)
  35.             .EntireRow.AutoFit
  36.             .EntireColumn.AutoFit
  37.         End With
  38.     End With
  39. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ bioleon69 ©ó 2017-5-1 10:27 ½s¿è

¥Ø«e¦¨¥\¥i°õ¦æ¤F,¤]¦hÁ«ª©¤W³\¦h¸ê·½
¦³´X­Ó°ÝÃD·Q½Ð±Ð





½Ð°Ý¤@¤U
1.¬°¤°»ò§Ú°õ¦æ¥X¨Ó«á·|¦³ªÅ¥Õªº¦C?
¬O­þÃä¥X¤F¤°»òª¬ªp?



2.¥i¥H§â¼g¤Jexcelªº¸ê®Æ,©w¸q¦¨¤@­ÓªF¦è¶Ü
¥i¥H¥Îwith  end with¨Ó±±¨î¤º®e(¥u±±¨î¼g¤Jªº³¡¤À)
¤ñ¤è»¡¦rÅé¤j¤p,¼e«×°ª«×,¤W¦â,§R°£/²M°£,µ¥µ¥
¤£·|²o°Ê¨ì©P³òªº¸ê®Æ

3.¥Ø«eµ{¦¡½XÁÙ¥iÀu¤Æ¶Ü?
¦]¬°·Q­n¦A§Ë¤@­Ó°j°é°õ¦æ«áÅý¥¦¶]1500¦¸
³oµ{¦¡½X·|¤£·|«Ü¦Y¨t²Î¸ê·½?(©È¹q¸£lag)

·PÁÂ
¥H¤Uµ{¦¡½X
  1. Option Explicit
  2. Dim ie As Object
  3. Sub ´ú¸Õ()
  4.   Set ie = CreateObject("InternetExplorer.Application")
  5.     With ie
  6.         .Navigate "http://norway.twsthr.info/StockHolders.aspx?stock=2330"
  7.         .Visible = True
  8.         Do While ie.Busy Or ie.readyState <> 4: DoEvents: Loop
  9.     End With
  10.     UsedRange.Clear
  11.     Ex_°Æµ{¦¡
  12. End Sub

  13. Private Sub Ex_°Æµ{¦¡()
  14. Dim A, i, ii
  15.     With ie
  16.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  17.         Set A = .Document.getElementsByTagName("table")(9)
  18.     End With
  19.     With ActiveSheet    '¥i«ü©w¤u§@ªí
  20.    
  21.         For i = 0 To A.Rows.Length - 296
  22.             For ii = 3 To A.Rows(i).Cells.Length - 1
  23.            .Cells(i + 1, ii - 2) = A.Rows(i).Cells(ii).innertext
  24.             Next
  25.             Next
  26.     With Cells
  27.             .EntireRow.AutoFit
  28.             .EntireColumn.AutoFit
  29.     End With
  30.     End With
  31.     ie.Quit
  32. End Sub
½Æ»s¥N½X
¥t¥~ªþ¤WÀÉ®×
test.rar (16.05 KB)

TOP

¥»©«³Ì«á¥Ñ bioleon69 ©ó 2017-4-30 22:24 ½s¿è

GBK¤j ½Ð±Ð¤@¤U
±q¤W­±ª¦¤å½m²ß,¥Ø«e¥i¥H±qEXCEL¥s¥XÂsÄý¾¹
¤§«á­n«ç»òŪ¨úºô­¶¤º®e,¤º®e¼g¤JEXCEL
A3¶}©l¼g¤J
³oÃä¯uªº¥d¦í¤F..
¥H¤U¬O¥Ø«eµ{¦¡½Xªº¶i«×
  1. Option Explicit
  2. Dim ie As Object
  3. Sub ¶°«O()
  4.     Dim keyin As String
  5.     keyin = Range("a1")
  6.     Set ie = CreateObject("InternetExplorer.Application")
  7.       With ie
  8.          .Navigate "http://norway.twsthr.info/StockHolders.aspx?stock=" & keyin & ""
  9.          .Visible = True
  10.          Do While ie.Busy Or ie.readyState <> 4: DoEvents: Loop
  11.      End With
  12. Ex_°Æµ{¦¡
  13. End Sub

  14. Private Sub Ex_°Æµ{¦¡()
  15.     Dim A As Object
  16.     With ie
  17.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  18.         Set A = .Document.getElementsByTagName("table")
  19.     End With
  20.     With ActiveSheet    '¥i«ü©w¤u§@ªí
  21.         .UsedRange.Clear






  22.     End With
  23.     ie.Quit
  24. End Sub
½Æ»s¥N½X
Àµ½ÐGBK¤jÀ°¦£«üÂI12...

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2015-9-14 06:14 ½s¿è

¦^´_ 28# aaron1059
¸Õ¸Õ¬Ý
À°§A§ä¥X¶Ç¦^´ÁÅv¸ê®Æªººô§}¤£¤@¼Ë.
  1. Option Explicit
  2. Sub Ex() 'Yahoo!©_¼¯ªÑ¥«--´ÁÅv
  3.     Dim ie As Object, k As Integer, S As Integer, jj As Integer, i As Integer, AA As Object
  4.     Set ie = CreateObject("InternetExplorer.Application")
  5.     ie.Navigate "https://tw.screener.finance.yahoo.net/future/aa03?opmr=optionfull&opcm=WTFO&opym=201510&random=0.01296169775357775"
  6.     ie.Visible = True
  7.     Do While ie.Busy Or ie.ReadyState <> 4: DoEvents: Loop
  8.     Set AA = ie.Document.getelementsbytagname("table")
  9.     With Sheets(1)
  10.         .Cells.Clear
  11.         k = k + 1
  12.         For S = 0 To AA.Length - 1                 '¤w§ä¥Xºô­¶ªºtable¤º®e¦b 5-7 ¤¤
  13.             For i = 0 To AA(S).Rows.Length - 1                 '¸ê®Æªº¦C¦ì
  14.                 For jj = 0 To AA(S).Rows(i).Cells.Length - 1   '¸ê®ÆªºÄæ¦ì
  15.                     .Cells(k, jj + 1) = AA(S).Rows(i).Cells(jj).INNERTEXT
  16.                 Next
  17.                 k = k + 1
  18.              Next
  19.           Next
  20.        End With
  21.      ie.Quit
  22. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¦³¤ß´N¦³ºÖ¡A¦³Ä@´N¦³¤O¡A¦Û³yºÖ¥Ð¡A¦Û±oºÖ½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD