Kristylee0228
New Member
- Joined
- Sep 8, 2011
- Messages
- 30
Hi Everyone, I am working on a Loop that I need to do the following: I have an active worksheet open with a list of Employees. I have the Loop locating a folder and opening a template. I am having a hard time finding out how to copy and paste Row 2, Column A, B and C of the Active Worksheet into the Template Columns D2, D3 and D4, respectively. Once the copy and paste is complete, I need the Loop to save the Template with the name in Column D2. Close the File, re-open the Template, copy & paste Row 3 from Active Sheet, etc... there maybe as many as 200+ names in the Active Sheet. Any help would be greatly appreciated. Below is the code I have so far.... (it's not much..)
VBA Code:
Sub CollectorListLoop()
Dim MyFolder As String, MyFile As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
MyFolder = .SelectedItems(1)
Err.Clear
End With
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
MyFile = Dir(MyFolder & "\", vbReadOnly)
Do While MyFile <> ""
DoEvents
On Error GoTo 0
Workbooks.Open Filename:=MyFolder & "\" & MyFile, UpdateLinks:=False
Sheets("collectors").Select
Range("A2").Select
Selection.Copy
Workbooks.Open Filename:="\\ncbfs1\businessintelligence\Automation\QA\LoopforCollectorList\NCB QA Scorecard_RPC_TEMPLATE.xlsm"
Sheets("RPC Call 1").Select
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Application.CutCopyMode = False
Workbooks(MyFile).Close SaveChanges:=False
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: