martinus1988
New Member
- Joined
- Aug 13, 2015
- Messages
- 15
Hi all,
I worked my way around this macro. What is does is that is will open an xlsx, copy all the data and drops it in a specific sheet inside the workbook.
The path of the file to copy is in column H.
The Sheet name of the to be pasted data is in column I.
Now i am looking for a way to loop from H2 to H99 (with the correct sheets names in I2-I99)
Can someone help me.
I worked my way around this macro. What is does is that is will open an xlsx, copy all the data and drops it in a specific sheet inside the workbook.
The path of the file to copy is in column H.
The Sheet name of the to be pasted data is in column I.
Now i am looking for a way to loop from H2 to H99 (with the correct sheets names in I2-I99)
Can someone help me.
Code:
Sub openAndCopyPartlist()
Dim wbCopy As Workbook
Dim wsCopy As Worksheet
Dim rngCopy As Range
Dim wbPaste As Workbook
Dim wsPaste As Worksheet
Dim rngPaste As Range
Set wbCopy = Workbooks.Open(ThisWorkbook.Sheets("Master").Range("H2").Value) 'This is Path location C:\\.....xlsx
Set wsCopy = wbCopy.Worksheets("Blad1") 'Is name of Sheet1
Set rngCopy = wsCopy.Range("a1:m100").EntireColumn 'Is range to copy
Set wbPaste = Workbooks("Voorraad beheer.xlsm") 'Is name of the paste location (workbook name)
Set wsPaste = wbPaste.Worksheets(ThisWorkbook.Sheets("Master").Range("I2").Value) 'This is Path location for the sheet. like test.
Set rngPaste = wsPaste.Range("a1") 'Past at cell 1
rngCopy.Copy
rngPaste.PasteSpecial
wbCopy.Close savechanges:=False
'now i am looking for a way to do this for the complete list H2 to H99 for sheet names: I2 to I99.
' Can someone help me how to make it a loop?
End Sub