JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
i have the following:
but say if i had filenames in Sheets("variables").Range("A1:A50")
how could i loop through them all ?
appreciate any help
i have the following:
Code:
Sub fg()Dim WB1 As Workbook, WB2 As Workbook
Dim WS1 As Worksheet, WS2 As Worksheet
file1 = Sheets("variables").Range("A1")
myFile = "C:\Temp\1\" & file1 & ".xlsx"
Set WB1 = ThisWorkbook
Set WS1 = WB1.Sheets("Sheet1")
Set WB2 = Workbooks.Open(myFile)
Set WS2 = WB2.Sheets("sheet1")
LR = WS1.Range("A65000").End(xlUp).Row + 1
WS2.Range("A1:A10").Copy: WS1.Range("A" & LR).PasteSpecial xlPasteValues
WB2.Close
End Sub
but say if i had filenames in Sheets("variables").Range("A1:A50")
how could i loop through them all ?
appreciate any help