I a trying to get this macro to work for my problem. I need to copy cells from one workbook and paste them into multiple workbooks. The macro I am trying to use is below. The code fails when I try to activate the sheet to paste the copied cells to (see Workbooks.Activate (FolderName & Fname) below).
Sub LoopThroughFiles()
FolderName = "S:\CRT-General Equipment Forecast Lists\2015 Forecast Information\2015 Country Templates\11-26-14 backup"
If Right(FolderName, 1) <> Application.PathSeparator Then FolderName = FolderName & Application.PathSeparator
Fname = Dir(FolderName & "*.xls")
'loop through the files
Do While Len(Fname)
With Workbooks.Open(FolderName & Fname)
' here comes the code for the operations on every file the code finds
'HERE if you want to execute the second macro for every file in the loop
Copy_discounted_costs_to_country_forecasts
End With
' go to the next file in the folder
Fname = Dir
Loop
End Sub
Sub Copy_discounted_costs_to_country_forecasts()
'
' Copy_discounted_costs_to_country_forecasts Macro
'
'
Windows("2015 Shortage Reconcile w Revised Discounted Costs.xlsm").Activate
Range("L1").Select
ActiveWindow.ScrollRow = 326
ActiveWindow.ScrollRow = 321
ActiveWindow.ScrollRow = 302
ActiveWindow.ScrollRow = 186
ActiveWindow.ScrollRow = 3
Range("L5:L1669").Select
Selection.Copy
Workbooks.Activate (FolderName & Fname)
Range("E8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Thanks in advance for any help with this...I am new to VBA.
Bookmarks