【ファイルのコピー】
Private Const motoF = NET & "0_dataDB\HEVdata.xlsm" ' 元ファイル
Private Const sakiF = NET & "1_HEV受付\取込データ\HEVdata.xlsm" ' 先ファイル
FileCopy motoF, sakiF
・シートのコピー
Workbooks("HEVdata.xlsm").Worksheets("データ").Copy After:=Workbooks("HEV受付.xlsm").Worksheets("マスタ")
【ファイルのコピー BackUp】
Dim today As String
Dim backupFolderPath As String
Dim backupFileName, backupFilePath As String
today = Format(Date, "yyyymmdd")
backupFolderPath = NET & "8_BackUp\" & today
If Dir(backupFolderPath, vbDirectory) = "" Then
MkDir backupFolderPath
End If
backupFileName = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)
backupFileName = backupFileName & "_" & Format(Date, "yyyymmdd") & ".bk"
backupFilePath = backupFolderPath & "\" & backupFileName
ActiveWorkbook.SaveCopyAs backupFilePath
【シートコピー変数】
Dim motoS As Worksheet 'bkF
Dim sakiS As Worksheet
Dim targetWorkbook As Workbook
Dim Filepath As String
Filepath = NET & "1_HEV受付\取込データ\取引先マスタ.xlsm"
If Dir(Filepath) = "" Then
MsgBox "指定したファイルは存在していません"
Exit Sub
End If
Set targetWorkbook = Workbooks.Open(Filepath)
Set sakiS = Workbooks("HEV受付.xlsm").Worksheets("管理データ")
Set motoS = Workbooks("取引先マスタ.xlsm").Worksheets("取引先住所マスタ")
' 取込コピー貼付け
motoS.Copy After:=sakiS
【条件項目を絞り込みコピーし変数に格納し一括貼り付け】←早い
sub 変数格納コピー()
Dim Target As Range
Set Target = Sheets("検収済データ").Cells(Rows.Count, 16).End(xlUp).Offset(1, 1) 'ここ
Range("A1").AutoFilter 8, ">0"
With Sheets("登録データ").Range("A1").CurrentRegion.Offset(1, 0)
.Resize(.Rows.Count - 1).Copy Target
.AutoFilter
End With
end sub