Excel vba复制并粘贴到工作表以在单独的工作表中掌握工作簿

时间:2015-12-02 17:28:20

标签: vba excel-vba excel

过去几个月我成功使用了以下代码。我现在需要将2个工作表上传到Master Workbook中的两个单独的工作表。

表格名称的细分如下:
表:“推荐”前往主表:“推荐报告”
表:“新账户”转到主表:“新账户报告”

下面是将数据从一个工作表发送到另一个工作表但在同一工作簿中将宏发送到主工作簿中的相应工作表的代码。我希望使用相同的代码,但只需要帮助告诉它。任何帮助表示赞赏。

Sub ExportNewAccounts()

Dim wbl As Workbook
Dim wbm As Workbook
Dim wsl As Worksheet
Dim wsm As Worksheet
Set wbl = ThisWorkbook
Set wbm = Workbooks.Open("\\PROFILER\2016 Global Tracker.xlsx")
Set wsl = wbl.Sheets("New Accounts")
Set wsm = wbm.Sheets("New Accounts Report")

If MsgBox("Are you sure you want to export all data entered?", vbYesNo + vbInformation) = vbNo Then Exit Sub
Application.ScreenUpdating = False

With wsl.Range("A4")
    Range(.Cells(1, 1), .End(xlDown).EntireRow).Copy
End With ****HERE***
wsm.Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
wbm.Save
wbm.Close
Application.ScreenUpdating = True
MsgBox ("Thanks, your data has been successfully exported.")

End Sub

Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next
filenum = FreeFile()
Open filename For Input Lock Read As #filenum
Close filenum
errnum = Err
On Error GoTo 0
Select Case errnum
Case 0
IsFileOpen = False
Case 70
IsFileOpen = True
Case Else
Error errnum
End Select
End Function

0 个答案:

没有答案