|
Sub CreateNewWork()
Dim WB As Workbook
Dim sht As Worksheet
Dim MyPath As String
Dim Range1 As Range
Dim range2 As Range
MyPath = "F:\KM.xls"
Set WB = Workbooks.Add
With WB
.SaveAs Filename:="Summary"
.Sheets(1).Name = "total"
End With
Set sht = WB.Worksheets.Add
With sht
.Name = "Shell"
End With
Set range2 = sht.Range("B1")
With Application.Workbooks(MyPath).Sheets(1)
' .Range(.Range("A1"), .Range("A1").SpecialCells(xlLastCell)).Copy sht.Range("B1")
Set Range1 = .Range(.Range("A1"), .Range("A1").SpecialCells(xlLastCell))
End With
Range1.Copy range2
WB.Save
WB.Close
End Sub
'加个Set 即可正常运行 |
|