I'm new to VB/VBA. Trying to get this to work.
I have found this: Looping a code through a folder of workbooks with VBA?
But it doesn't quite address what I'm trying to do. I have ~60 .CSV files that are all clean and conformed, and I want to take these and put them onto an Excel template using a VBA. I was able to get one working using the "Record Macro" Function:
Range("A2:A33").Select
Selection.Copy
Workbooks.Open Filename:="C:\Users\rs\Desktop\F15-Template.xlsx"
Range("A6").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Windows("List01.csv").Activate
Range("B2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("F15-Template.xlsx").Activate
Range("H2:J2").Select
ActiveSheet.Paste
Windows("List01.csv").Activate
Range("D2").Select
Application.CutCopyMode = False
Selection.Copy
Windows("F15-Template.xlsx").Activate
Range("H3:J3").Select
ActiveSheet.Paste
But as you can tell this is for one list onto the template.
The things I'd like to do in addition to copy/pasting from list to XLS template are:
- Make the above code work with a directory
- Save As ListName01.xls after the copy/paste merge
- If possible, apply a batch "Protect Sheet" to these files.
The lists live in C:\Users\rs\Desktop\lists
and the template is on the bare Desktop
-- Whatever you can do to help would be well appreciated.
If VB/VBA is the wrong tool for the job, please point me in the right direction. Thanks in advance!