這應該讓你開始: 在自己的Excel工作簿使用VBA,有它提示用戶他們的數據文件的文件名, 然後只複製固定的範圍到目標工作簿(可能是相同的工作簿作爲您的宏啓用一個,或第三個工作簿)。 這裏是如何工作的快速VBA例如:
' Get customer workbook...
Dim customerBook As Workbook
Dim filter As String
Dim caption As String
Dim customerFilename As String
Dim customerWorkbook As Workbook
Dim targetWorkbook As Workbook
' make weak assumption that active workbook is the target
Set targetWorkbook = Application.ActiveWorkbook
' get the customer workbook
filter = "Text files (*.xlsx),*.xlsx"
caption = "Please Select an input file "
customerFilename = Application.GetOpenFilename(filter, , caption)
Set customerWorkbook = Application.Workbooks.Open(customerFilename)
' assume range is A1 - C10 in sheet1
' copy data from customer to target workbook
Dim targetSheet As Worksheet
Set targetSheet = targetWorkbook.Worksheets(1)
Dim sourceSheet As Worksheet
Set sourceSheet = customerWorkbook.Worksheets(1)
targetSheet.Range("A1", "C10").Value = sourceSheet.Range("A1", "C10").Value
' Close customer workbook
customerWorkbook.Close
來源
2011-10-24 15:30:59
jdh
另一個......鏈接點擊進入製藥業騙局。請刪除並用Wayback機器副本進行更換。同時,讀者請注意點擊上面的鏈接(vba4all [dot] com ...)。 –