I have an Excel Document and from this document I read some value and would like to insert these into another Excel workbook. I would like to open the workbook in the existing workbook then search for the specific field and set the values. How can I open such an additional workbook? and then set the values?
Best regards
Matthias
assuming you know a little VBA, here is a framework to get started.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.