0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【VBA】別ファイルの指定したシートを取り込む

Posted at
Dim SS1log As String
Dim wbMoto, wbSaki As Workbook
Worksheets("任意のシート").Activate '貼り付け先のシートを指定するとよい
Set wbSaki = ActiveWorkbook  'データの貼り付け先の変数

Application.DisplayAlerts = False
   
SS1log = ThisWorkbook.Path & "\" & "SS1ログ.xlsx"  '取り込むデータファイル

Workbooks.Open fileName:=SS1log, ReadOnly:=True, UpdateLinks:=0 '取り込むデータファイルを読み取り専用で開きます
Set wbMoto = Workbooks.Open(SS1log)


wbMoto.Worksheets("Sheet1").Range("A:CC").Copy  '取り込むデータファイルのSheetからセルA:CCの範囲をコピー
    
wbSaki.Worksheets("SS1ログ").Range("A1").PasteSpecial xlPasteFormulasAndNumberFormats  '取り込み元 シート名「項目」A1から貼り付け
    
Application.CutCopyMode = False  'コピー切り取りを解除
    
wbMoto.Close False  '取り込み元のファイルを閉じる

Application.DisplayAlerts = True
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?