Sub 加入檔案()
fds = Application.GetOpenFilename("Excel Files (*.xls;*.xlsx), *.xls;*.xlsx", , , , True)
If IsArray(fds) Then
For i = 1 To UBound(fds)
[A1].Offset(i - 1) = fds(i)
Next
End If
End Sub
請問在執行時如果要選擇性的將檔案貼到指定的sheet上(不同sheet)
以下執行程式要怎麼改寫
(原本以下程式 只是將開啟的資料貼在同sheet上,
Sub 執行()
For Each a In Range([A1], Cells(Rows.Count, 1).End(xlUp))
With Workbooks.Open(a)
.Sheets(1).[A1:C6].Copy ThisWorkbook.Sheets("Result").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Close 0
End With
Next
End Sub
謝謝作者: iverson105 時間: 2019-12-24 08:54
Sub 加入檔案()
fds = Application.GetOpenFilename("Excel Files (*.xls;*.xlsx), *.xls;*.xlsx", , , , True)
If IsArray(fds) Then
For i = 1 To UBound(fds)
[A1].Offset(i - 1) = fds(i)
Next
End If
End Sub
請問在執行時如果要選擇性的將檔案貼到指定的sheet上(不同sheet)
以下執行程式要怎麼改寫
(原本以下程式 只是將開啟的資料貼在同sheet上,
Sub 執行()
For Each a In Range([A1], Cells(Rows.Count, 1).End(xlUp))
With Workbooks.Open(a)
.Sheets(1).[A1:Z20000].Copy ThisWorkbook.Sheets("Result").Cells(Rows.Count, 1).End(xlUp)
.Close 0
End With
Next
End Sub
謝謝作者: adrian_9832 時間: 2019-12-25 00:02
Sheets("工作表1").Activate
fds = Application.GetOpenFilename("Excel Files (*.xlsm;*.xlsx), *.xlsm;*.xlsx", , , , True)
If IsArray(fds) Then
For i = 1 To UBound(fds)
[A1].Offset(i - 1) = fds(i)
Next
End If
Sheets("工作表1").Activate
For Each A In Range([A1], Cells(Rows.Count, 1).End(xlUp))
With Workbooks.Open(A)
Sheets.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
.Close 0
End With
Next