|
Sub YDay_DataCopy()
Dim Cnt As Integer
Dim Snm As String, MyF As String
With Application
.ScreenUpdating = False
.DiplayAlerts = False
End With
Snm = Format(Date - 1, "yymmdd") & "入力Data"
MyF = "\\フォルダの場所" & "\" & Snm & ".csv"
If Dir(MyF) = "" Then
MsgBox "前日のデータファイルがありません", 48
GoTo ELine
End If
Cnt = Worksheets.Count
With Worksheets(Cnt)
If .Name = Snm Then
MsgBox "昨日のデータは既に取り込まれています", 48
GoTo ELine
ElseIf Right$(.Name, 6) = "入力Data" Then
.Delete: Cnt = Cnt - 1
End If
End If
Workbooks.Open MyF
With ActiveWorkbook
.Worksheets(1).Copy After:= _
ThisWorkbook.Worksheets(Cnt)
.Close False
End With
ELine:
With Application
.ScreenUpdating = True
.DiplayAlerts = True
End With
End Sub
で、どうでしょーか ?
|
|