0

我只是想知道我下面的代码是否有可能从一个工作簿中的两个单独的工作表中收集内容,并将其复制到另外两个单独的工作表和一个工作簿中。下面是我正在使用的代码,但我只是不知道如何命令它具有多个源和目标。以下是我目前正在使用的代码。任何形式的帮助将不胜感激。

Sub ImportData()

'To Clear Project Data Sheet
    Application.ScreenUpdating = False
    Sheets("Projects Data").Visible = True
    Sheets("Projects Data").Cells.Clear
    Sheets("Projects Data").Visible = False
    

    Dim wb1 As Workbook, wb2 As Workbook
    Dim Ret1, Ret2
    Dim ws As Worksheet
 
    Set wb1 = ActiveWorkbook
 
    '~~> Get the File
    Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
    , "Please select file")
    If Ret1 = False Then Exit Sub
 
    Set wb2 = Workbooks.Open(Ret1, UpdateLinks:=False)
    Set ws = wb2.Sheets("East Region")
    If ws.FilterMode Then
    ws.ShowAllData
End If
    Application.DisplayAlerts = False
    ws.Range("a7").CurrentRegion.Copy Destination:=wb1.Worksheets("Projects Data").Range("A7")
    wb2.Close SaveChanges:=False
    Set wb2 = Nothing
    Set wb1 = Nothing
    
'To Copy paste data
    Sheets("Projects Data").Visible = True
    Sheets("Projects Data").Cells.Copy
    Sheets("Projects Data").Cells.PasteSpecial Paste:=xlPasteValues
    Sheets("Projects Data").Visible = False
    
    
    
End Sub
4

0 回答 0