I have a column of data (paths to files) this column can have 5 to 200 filled cells depending on the project. What I am wanting to do is to write a loop so that it goes through this column and opens each file listed until it gets to the end of the column. I found what I thought I needed on this board from 2002 from user zzydhf.
Sub FileOpenLoop()
Dim ThisFileName, FileToOpen As String
ThisFileName = ActiveWorkbook.Name
Range("a1").Select
Do While ActiveCell <> ""
FileToOpen = ActiveCell
Workbooks.Open(Filename:=FileToOpen).RunAutoMacros _
Which:=xlAutoOpen
'run your macros and close file
Windows(ThisFileName).Activate
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
End Sub
But I am having issues getting this loop to work, it will open the first file but then the macro just quits, i've tried adjusting certain parts of the code to get it to work but I was hoping someone could point me in the right direction.
Thanks.
Sub FileOpenLoop()
Dim ThisFileName, FileToOpen As String
ThisFileName = ActiveWorkbook.Name
Range("a1").Select
Do While ActiveCell <> ""
FileToOpen = ActiveCell
Workbooks.Open(Filename:=FileToOpen).RunAutoMacros _
Which:=xlAutoOpen
'run your macros and close file
Windows(ThisFileName).Activate
ActiveCell.Offset(1, 0).Range("A1").Select
Loop
End Sub
But I am having issues getting this loop to work, it will open the first file but then the macro just quits, i've tried adjusting certain parts of the code to get it to work but I was hoping someone could point me in the right direction.
Thanks.