我将简要描述我想要的内容:我有6个“主”文件,每个文件包含40个工作表,如下所示:AG工作簿的HR Gp 1至HR Gp 40,ER工作簿的FB Gp 1至Gp 40,等等。所有工作表都是“平”。
我已经设法创建了一个宏(使用Excel Mac 2011),该宏适用于一组(代码在底部),但是我无法使其成功“循环”。
感谢您对排序循环的任何帮助非常感谢,迈克
Sub Macro3()
'
' Macro3 Macro
'turn off screen
With Application
' .ScreenUpdating = False only removed while testing
' .EnableEvents = False
'.Calculation = xlCalculationManual disbled for the moment
End With
'get the path to desktop
Dim sPath As String
sPath = MacScript("(path to desktop folder as string)")
'give a name to new work book for macro use
Dim NewCaseFile As Workbook
'open new workbook
Set NewCaseFile = Workbooks.Add
'Move group 1's sheets to NewcaseFile : 1 sheet from 6 workbooks...
Windows("AG.xlsx").Activate
Sheets("HR gp 1").Select
Sheets("HR gp 1").Move Before:=NewCaseFile.Sheets(1)
Windows("ER.xlsx").Activate
Sheets("F&B gp 1").Select
Sheets("F&B gp 1").Move Before:=NewCaseFile.Sheets(1)
Windows("CS.xlsx").Activate
Sheets("Acc gp 1").Select
Sheets("Acc gp 1").Move Before:=NewCaseFile.Sheets(1)
Windows("EV.xlsx").Activate
Sheets("Mkt gp 1").Select
Sheets("Mkt gp 1").Move Before:=NewCaseFile.Sheets(1)
Windows("JD.xlsx").Activate
Sheets("Rdiv gp 1").Select
Sheets("Rdiv gp 1").Move Before:=NewCaseFile.Sheets(1)
Windows("PG.xlsx").Activate
Sheets("Fac gp 1").Select
Sheets("Fac gp 1").Move Before:=NewCaseFile.Sheets(1)
'Save the created file for Group1
ActiveWorkbook.SaveAs Filename:=sPath & "gp 1.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close False
'turn screen back on
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
偶然的你
皈依舞
缥缈止盈