0
현재 파일의 데이터를 다른 통합 문서로 복사하는 VBA 스크립트가 있습니다. 수동으로 실행하면 코드가 잘 작동합니다. 현재 통합 문서의 데이터를 복사 한 다음 다른 통합 문서를 열고 데이터를 붙여 넣은 다음 마지막으로 닫습니다.Excel 2013 - 매크로 바로 가기가 제대로 작동하지 않지만 매크로가 수동으로 활성화되어 정상적으로 작동합니다.
그러나이 매크로를 바로 가기로 실행하면 데이터를 붙여 넣기 만하고 대상 통합 문서를 닫지 않습니다.
[your code]
End If
Next i
debug.print wbk.name
wbk.Close True
End Sub
이 무엇을 인쇄 않습니다
Sub CopyToBMD()
'
' CopyToBMD Macro
' Copy Lastest BMD price to appropriate day in the table
'
'
Dim target As Integer
Dim LDate As String
Sheets(1).Select
Range("B48:R48").Copy
LDate = Date
If Cells(40, 2).Value = Cells(1, 2).Value Then
target = 2
Else
target = 8
End If
' Paste data to BMD&CBOT
Dim wbk As Workbook
Dim folderPath As String
Dim ws As Worksheet
'Find file location
folderPath = Application.ActiveWorkbook.Path
FilePath = Dir(folderPath & "\BMD&CBOT.xlsx")
Set wbk = Workbooks.Open(folderPath & "\" & FilePath)
Set ws = wbk.Sheets("CPO-Jun 16")
' i is the row number
Dim i As Integer
For i = 4 To 34
If Cells(i, 1).Value = LDate Then
ws.Cells(i, target).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Next i
wbk.Close True
End Sub