I have a macro that look to a cell for a file name, opens that file and copies some data to the worksheet I'm in and then closes the file. It works fine up to the point of closing the file.... and it just stays open. I was hoping someone could look at the macro below and see if they can spot my error. Just to explain the logic a bit, the macro is in a workbook named "familes" and the worksheet in named "Wk content". It opens a file named in cells (x, y) and the rest should be self explanatory.
Any help would be greatly appreciated!
Sub abridor()
Dim x, y, c, r As Integer
Dim trai As Double
x = 3
y = 27
r = 4
c = 5
With Workbooks("families").Worksheets("Wk content")
Do While Cells(x, y).Value <> Empty
Workbooks.Open(Cells(x, y).Value).Worksheets("Sheet2").Activate
trai = Range("c5").Value
Workbooks("families").Worksheets("Wk content").Activate
Cells(r, c).Value = trai
Workbooks(Cells(x, y).Value).Close savechanges:=False
r = r + 1
x = x + 1
Loop
End With
End Sub
Bookmarks