我有一个代码,用于将各种文件复制并粘贴到主文件中:
Sub code()
Dim MyFile As String
Dim Filepath As Variant
Filepath = InputBox()
MyFile = Dir(Filepath)
Do while Len(MyFile) > 0
If MyFile = ''Umaster.xlsm'' Then
Exit Sub
End If
Windows(''Umaster.xlsm'').Activate
Sheets.AddAfter:=Sheets(Sheets.Count)
Workbooks.Open(Filepath & MyFile)
Sheets(''1'').Select
Cells.Select
Selection.Copy
Windows(''Umaster.xlsm'').Activate
Selection.PasteSpecial Paste:=xlPaste, Operation:=xlNone, SkipBlanks_ :=False, Transpose:=False
Sheets.Add After:= Sheets(Sheets.Count)
Windows(MyFile).Activate
ActiveWindow.Close SaveChanges :=False
MyFile = Dir
Loop
End sub
我还有一些标签要复制,例如。表格(''''')。选择等等。
如何使用UserForm仅运行用户选定的选项卡组合来复制和粘贴?