LoginSignup
5
6

More than 5 years have passed since last update.

Excel 情報収集用マクロメモ1

Posted at

※記載内容はメモとして作成しているため、修正が必要な部分があるかもしれません。

指定したWEBページから表をコピーするマクロ

With ActiveSheet.QueryTables.Add _
     (Connection:="URL;http://info.finance.yahoo.co.jp/ranking/?kd=1&tm=d&mk=1", _
     Destination:=Range("$B$8"))

    .WebSelectionType = xlSpecifiedTables
    .WebTables = "1"

    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = True

    .Refresh

End With

指定値
Connection              URL指定
Destination              貼り付け先指定
WebSelectionType = xlSpecifiedTables       webページ内の一部を取得する
WebTables = "1"              表1を指定、同ページ内で複数指定する場合は"1,2,3"と、要素番号を指定

テキスト形式を指定
WebFormatting = xlWebFormattingNone
WebPreFormattedTextToColumns = True

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6