How to change this code to copy data to existing workbooks (the only difference they are in .xlsm format, the names of files are 1.xlsm,...,50.xlsm) not to create new ones (all files are in the same folder)? And how to specify range lm = Range("B2,G2,L2") if there are more cells (every 5-th cell, starting from B2)?
Sub CopyM()
Dim lm As Range, r As Long, c As Long
Set lm = Range("B2,G2,L2"): Application.ScreenUpdating = False
For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Workbooks.Add
For c = 0 To 4
lm.Offset(r - 2, c).Copy Cells(r + c, 2)
Next
With Workbooks(Workbooks.Count)
.SaveAs lm.Offset(r - 2, -1).Value: .Close
End With
Next
Application.ScreenUpdating = True
End Sub
Bookmarks