20210210 1411
codes
Sub zSaveAsNewExcelFile()
zpath = ActiveWorkbook.Path
zFile = zpath & "\_investment proposal.xlsx"
zcur = ActiveWorkbook.Name
Workbooks.Add
znew = ActiveWorkbook.Name
Workbooks(zcur).Activate
znmb_report = 0
For i = 1 To ActiveWorkbook.Sheets.Count
If Left(Worksheets(i).Name, 6) = "report" Then
znmb_report = znmb_report + 1
End If
Next i
For i = 1 To znmb_report
zsheet = "report" & i
Workbooks(zcur).Activate
Workbooks(zcur).Sheets(zsheet).Select
'Selection.Copy
Application.CutCopyMode = False
zNmbsheet = Workbooks(znew).Sheets.Count
Sheets(zsheet).Copy before:=Workbooks(znew).Sheets(zNmbsheet)
Workbooks(znew).Activate
Workbooks(znew).Sheets(zsheet).UsedRange.Select
'Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next i
Workbooks(znew).SaveAs Filename:=zFile
Workbooks(zcur).Activate
Workbooks(zcur).Sheets("report1").Select
End Sub
'[PA] 업무자동화 > [XL]Excel & VBA' 카테고리의 다른 글
XL Relationship Database, Table (0) | 2021.02.17 |
---|---|
XL Range.Find method (0) | 2021.02.11 |
XL saving/printing multiple sheets in on PDF file (0) | 2021.02.11 |
XL internal data model (0) | 2021.02.08 |
XL book, Supercharge Excel when you learn to write DAX for power pivot (0) | 2021.02.08 |