此宏将具有数字名称的Excel工作表复制到另一个Excel工作簿。
例如,只有标题为6位数的工作表。例如“140655”。
我还想复制那些有标准英语名称(如“预算”)的工作表。
Const CalcDelay = 0.00000578704
Dim CopyRange As String
Dim PasteRange As String
Dim ScanFileOpen As Byte
Dim ScanCount As Byte
Dim ScanSaveSpec As String
Dim ScanSaveFile As String
Dim ReturnWindow As String
Dim ReportFile As String
Dim ExcelVersion As String
Sub OpenReportFile()
ReturnWindow = [ProcessWinSpec].Value
If [ReportFileFlag].Value = True Then
Application.ScreenUpdating = False
Workbooks.Open Filename:=[ReportFileSpec].Value
Windows(ReturnWindow).Activate
Application.ScreenUpdating = True
Else
MsgBox ("Error: File not found")
End If
End Sub
Sub DoScan()
Dim Work As Variant
Dim X As Interger
ReturnWindow = [ProcessWinSpec].Value
ReportFile = [ReportFileName].Value
ExcelVersion = IIf([FileNameExt].Value = ".xls", 2003, 2013)
For Each Work In [ScanFlags]
ScanFileOpen = 0
ScanCount = 0
If Work.Value = 1 Then
[ScanName].Value = Work.Offset(0, 1).Value
[ScanCalcRange].Calculate
ScanSaveFile = [ScanFile].Value
ScanSaveSpec = [ScanSpec].Value
For X = Work.Offset(0, 2).Value To 1 Step -1
ScanTabName = Work.Offset(0, X + 2).Value
[ScanTab].Value = ScanTabName
[ScanCalcRange].Calculate
If [ReadFlag].Value = 1 Then DoCopyTab
Next
End If
If ScanFileOpen = 1 Then
ActiveWorkbook.Save
ActiveWindow.Close
End If
Next
End Sub
1条答案
按热度按时间jgwigjjp1#
关于你的问题,如果文件有一个特定的名字,如何执行宏,可能最好的方法是创建一个单词数组,然后循环通过它们寻找匹配。
正如你在评论中所看到的,你的问题没有得到最好的反馈,如果这不起作用,你可能需要考虑删除你的问题,并在更仔细地阅读How to ask a question后重新发布