A Challenging VBA - Copy data from multiple workbooks into one workbook - Not as easy as it sounds
All Here is my code. I do not receive any errors but I can't seem to get it to function and make the changes needed.
First and formost, thanks for all you do. I am slowly learning alot about VBA and with your help I may learn faster.
I also have a link to the work books on my Skydrive account https:// skydrive.live.com /redir?resid= 4717926F71CD602F!109 I have spaces in between the link because it will not let me paste links on this forum.
Microsoft 2007 Excel Windows 7 Enterprise
I need Excel VBA code for the following; Main Workbook Name “Master Backshop.xlsm”
Search Cell AF:AF for a matching Workbook name located in L:\IO\CAPACITY RESOURCE MANAGEMENT\PPC\Kitting Schedules\Packing Lists (Cell AF contains the workbook name associated with the file information on that row).
If it finds a match to one of the cells in AF Master Backshop it opens that Workbook copies and paste’s the following cells from that found workbook.
For Example it searches AF and see’s in cell AF6 0123-LIP WO# 0001 matches to a workbook named 0123-1LIP WO# 0001 in L: Drive
?
Searched Work Book Master Backshop Workbook
Copy Name: DATE_KIT_COMP Paste in Column U (Column Q I want to be able to enter any data I want unless there is a date in Column U. If there is then I want that date entered in Column Q as well.)
Copy Name: LI_S Paste in Column V Copy
Name: COMPLETE Paste in Column X
Copy Name: KIT_COST Paste in Column AC
Sub OpenMatchedDocuments()
Dim baseDir As String
Dim targetSheet As Worksheet
Dim srcSheet As Worksheet
Dim afCol As Range
Dim wk As Workbook
baseDir = "L:\IO\CAPACITY RESOURCE MANAGEMENT\PPC\Kitting Schedules\Packing Lists"
Set targetSheet = Application.ActiveSheet
Set afCol = targetSheet.Range("AF5", "AF" & targetSheet.UsedRange.Columns.Count)
For Each cell In afCol.Cells
If Dir(baseDir & cell.Text & ".xlsx") <> "" Then
Set wk = Application.Workbooks.Open(baseDir & cell.Text & ".xlsx")
Set srcSheet = Application.ActiveSheet
On Error GoTo ErrorHandler
targetSheet.Range("V" & cell.Row).FormulaR1C1 = srcSheet.Range("LI_S").Text
targetSheet.Range("X" & cell.Row).FormulaR1C1 = srcSheet.Range("COMPLETE").Text
targetSheet.Range("AC" & cell.Row).FormulaR1C1 = srcSheet.Range("KIT_COST").Text
' add other mappings
ErrorHandler:
wk.Close (False)
Set wk = Nothing
End If
Next
Recent comments
5 years 42 weeks ago
6 years 28 weeks ago
6 years 40 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 49 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago