Hi , I am trying to get this code work in a way the 3 for next statements work in order, first change r, then f, then s . The next statement right now is going straight to S. I am trying to copy sheets from one file to different files with different names in different folders.
Thank you
Sub Macro1()
Dim directory As String, sheet As Worksheet, i As Integer, j As Integer, fileName As String, r As Range, A1 As Range
Dim sh As Worksheet, s As Range, MySource As Object, f As Range, FName As String, fs As Range, wkb As Workbook, FPath As String
Application.ScreenUpdating = False
Sheets("Departments codes").Select
For Each r In Sheets("Departments codes").Range("l6", Range("l" & Rows.Count).End(xlUp)) ' file name
For Each f In Sheets("Departments codes").Range("H6", Range("H" & Rows.Count).End(xlUp))
For Each s In Sheets("Departments codes").Range("k6", Range("k" & Rows.Count).End(xlUp))
Sheets("Departments codes").Select
fileName = r.Value
Set sh = Worksheets(s.Value)
FName = f.Value & ".xlsm"
Workbooks.Open (fileName)
Windows("Monthly Results Comments.xlsm").Activate
sh.Select
sh.Copy Before:=Workbooks(FName).Sheets(2)
Range("H20").Select
ActiveWindow.SmallScroll Down:=-18
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B13").Select
Application.CutCopyMode = False
ActiveWindow.SmallScroll Down:=-3
ActiveWorkbook.Save
ActiveWindow.Close
Next r
Next f
Next s
End Sub