Option Explicit ------------------------------------------------------------------------ Sub 実績を取得する() 'Excel 2007バージョンのファイルの取得 'Microsoft ActiveX Data Objects 2.1 Library 以上 2.8は不可 'ツール - 参照設定にてチェックを付ける。 Dim Cnn As ADODB.Connection Dim Rec As ADODB.Recordset Dim intMon As Integer Worksheets("Sheet2").Select Range("B3:O50").ClearContents Set Cnn = New ADODB.Connection Cnn.Provider = "Microsoft.ACE.OLEDB.12.0" 'Excel97,2000のブックはExcel8.0で設定する Cnn.Properties("Extended Properties") = "Excel 12.0" Cnn.Open "E" & ":" & "\" & "Book2.xlsm" Set Rec = New ADODB.Recordset Set Rec.ActiveConnection = Cnn Rec.Open "[集計$F21:F22]", , adOpenKeyset, adLockPessimistic, adCmdTable Worksheets("Sheet2").Range("B4").CopyFromRecordset Rec Rec.Close Cnn.Close Set Rec = Nothing Set Cnn = Nothing End Sub