[英]Excel VBA - Saved Workbook in loop within macro…Workbook fails to open
[英]Open an Excel Workbook within another Excel Workbook and then fill a Formular in this workbook
我有一個Excel文檔,我從該文檔中讀取了一些值,並希望將它們插入另一個Excel工作簿中。 我想在現有工作簿中打開工作簿,然后搜索特定字段並設置值。 如何打開這樣的額外工作簿? 然后設置值?
最好的祝福
馬蒂亞斯
假設您了解一些VBA,這里是一個入門框架。
Sub copyBetweenWorkbooks()
Dim wkbkA As Workbook
Dim wkbkB As Workbook
Dim copyValues As Range
Dim directory As String, fileName As String, i As Long, j As Long
Application.ScreenUpdating = False
directory = "c:\test\"
fileName = Dir(directory & "yourspreadsheet.xls")
Set wkbkA = ThisWorkbook
Set copyValues = wkbkA.Sheets({ put sheet here}).Range({put range here})
Set wkbkB = Workbooks.Open(directory & fileName)
With wkbkB
'do your stuff here
End With
'close your stuff if you need to
Workbooks(fileName).Close
Application.ScreenUpdating = True
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.