从名称不同的其他工作簿中获取数据 - 要求用户 select 他们

Taking data from other workbooks which vary in name - asking user to select them

所以我在上一个问题上找到了这个惊人的答案,我只是想知道如何在指定位置开始搜索 window - 让他们不必每次都搜索多个文件夹。抱歉,我不能只回复原来的 post,自从我刚刚创建帐户以来,我有 1 个声誉。

请帮忙! 谢谢,

选项显式

Sub Sample()
    Dim wb1 As Workbook, wb2 As Workbook
    Dim Ret1, Ret2

    Set wb1 = ActiveWorkbook

    '~~> Get the first File
    Ret1 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
    , "Please select first file")
    If Ret1 = False Then Exit Sub

    '~~> Get the 2nd File
    Ret2 = Application.GetOpenFilename("Excel Files (*.xls*), *.xls*", _
    , "Please select Second file")
    If Ret2 = False Then Exit Sub

    Set wb2 = Workbooks.Open(Ret1)
    wb2.Sheets(1).Cells.Copy wb1.Sheets(1).Cells
    wb2.Close SaveChanges:=False

    Set wb2 = Workbooks.Open(Ret2)
    wb2.Sheets(1).Cells.Copy wb1.Sheets(2).Cells
    wb2.Close SaveChanges:=False

    Set wb2 = Nothing
    Set wb1 = Nothing
End Sub

已解决。

对于任何需要解决方案的人,我通过在打开每个对话框之前设置目录默认文件夹来解决这个问题。

ChDir "C:\places\we\hide\things"

后面是对话框打开代码。很有魅力,如果您需要更好的解释,请发表评论。