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

QueryTables­«½Æ¬d¸ß¡A¦p¦óÂл\¤W¤@µ§¬d¸ß

QueryTables­«½Æ¬d¸ß¡A¦p¦óÂл\¤W¤@µ§¬d¸ß

¦U¦ì¤j¤j¦w¦w
§Ú¨Ï¥ÎQueryTable§@¬d¸ß®É¡A
¨C¦¸¬d¸ß¤@­ÓªÑ»ù¸ê®Æ
´N·|§â«e¤@­Ó¤w¸g¬d¦nªºªÑ»ù¸ê®Æ©¹®ÇÃäÀ½
¨ì³Ì«áÀx¦s®æ´N·|¥ÎÁj
§Ú§Æ±æªº¬O¨C¦¸¬d¸ß³£¨Ï¥Î¦P¤@­Ó½d³òªºÀx¦s®æ¡A
·N§Y§â¤W¤@­Ó¬d¦nªºªÑ»ù¸ê®ÆÂл\(¤£­n©¹®ÇÃäÀ½)
§Ú¸Ó«ç»ò­×§ï©O¡H
µ{¦¡½X¦p¤U
            With ActiveSheet.QueryTables.Add(Connection:="URL;https://tw.finance.yahoo.com/q/q?s=" & stockID, Destination:=Sheets(10).Range("A1"))
                .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 = "6"
                .WebPreFormattedTextToColumns = True
                .WebConsecutiveDelimitersAsOne = True
                .WebSingleBlockTextImport = False
                .WebDisableDateRecognition = False
                .WebDisableRedirections = False
                .Refresh BackgroundQuery:=False
                .Name = .ResultRange.Cells(3, 1)
            End With

  1. Sub ex()
  2.         Range("A:L").Clear

  3.         With ActiveSheet.QueryTables.Add(Connection:="URL;https://tw.finance.yahoo.com/q/q?s=" & 1101, Destination:=Range("A1"))
  4.             .WebSelectionType = xlSpecifiedTables
  5.             .WebFormatting = xlWebFormattingNone
  6.             .WebTables = "6"
  7.             .Refresh BackgroundQuery:=False
  8.             .Delete
  9.          End With
  10. End Sub
½Æ»s¥N½X
¦^´_ 1# tsunamix03

TOP

¦^´_ 1# tsunamix03

¦bµ{¦¡½X¶×¤J¬d¸ß®É,«ü©w³oÄݩʪº°Ñ¼Æ­È
  1. .RefreshStyle = xlOverwriteCells
½Æ»s¥N½X
VBA ªº»¡©ú
  1. RefreshStyle ÄÝ©Ê
  2. ½Ð°Ñ¾\®M¥Î¦Ü½d¨Ò¯S©w¶Ç¦^©ÎªÌ³]©w«ü©w¤u§@ªí¤¤¦Cªº´¡¤J©Î§R°£¼Ò¦¡¡A¥H´£¨Ñ¬d¸ß¶Ç¦^ªº°O¿ý¶°ªº¦C¼Æ¡CŪ/¼g XlCellInsertionMode¡C

  3. XlCellInsertionMode ¥i¥H¬O³o¨Ç XlCellInsertionMode ±`¼Æ¤§¤@¡C
  4. xlInsertDeleteCells¡C´¡¤J©ÎªÌ§R°£³¡¥÷¦C¥H¾AÀ³·s°O¿ý¶°©Ò»Ý­nªº¹ê»Ú¦C¼Æ¡C
  5. xlOverwriteCells¡C¤£¦b¤u§@ªí¤¤·s¼W·sªºÀx¦s®æ©Î¦C¡C¦pªG·¸¥X«h¨ú¥N©P³òªºÀx¦s®æªº¤º®e¡C
  6. xlInsertEntireRows¡C·s¼W¸ê®Æ recordset ¤¤ªº©Ò¦³¦C¡A¨Ã¥B¤¹³\·¸¥X­ì¦³°Ï°ì¡C¤u§@ªí¤¤¨S¦³³Q§R°£ªºÀx¦s®æ©Î¦C¡C
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·P®¦¼Ó¤W¨â¦ì°ª¤Hªº¸Ñµª¡A¤w¸g¶¶§Q¸Ñ¨M°ÝÃD¤F:)

TOP

        ÀR«ä¦Û¦b : ¤H¥Í³Ì¤jªº¦¨´N¬O±q¥¢±Ñ¤¤¯¸°_¨Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD