我在copy.xls工作表中有一个工作表滚动计划。我想将它复制到范围A1中的工作表NO1中的Book1.xls工作表:H6
Book.xls中的宏
Sub CopytoPS()
Dim sfil As String
Dim owbk As Workbook
Dim sPath As String
sPath = "C:\Users\Nirmala\Desktop\website" 'Change the file path for your purposes
sfil = Dir(sPath & "copy.xls")
Range("B6:H6").Copy
Set owbk = Workbooks.Open(sPath & sfil)
owbk.Sheets("RollinPlan").Range("B6:H6").End(xlUp).Offset(1, 0).
PasteSpecial xlPasteValues
owbk.Close True 'Save opened workbook and close
sfil = Dir
End Sub
答案 0 :(得分:0)
执行以下操作:
1)打开copy.xls
并复制范围B6:H6
2)将数据粘贴到工作表Book1
上的工作簿A1:H6
中{1}}
NO1
请注意,我不太清楚为什么要复制的数据范围(即Sub CopyData()
Dim filePath As String, wb As Workbook
filePath = "C:\Users\Nirmala\Desktop\website" 'Change the file path for your purposes
Set wb = Workbooks.Open(Filename:=filePath & "\" & "copy.xls")
wb.Worksheets("Rolling Plan").Range("B6:H6").Copy Destination:=ThisWorkbook.Worksheets("NO1").Range("A1:H6")
wb.Close
End Sub
)远大于实际复制的范围(即A1:H6
)。