Jo Ann K.

asked • 03/20/23

Visual Basic Question

Hi!


I have the below code that allows me to have a list of employee names and a template and it will copy the workbook template multiple times and rename based on the names in the list in excel. I'd like to also insert the name from the list into the copied workbook template. I do not know how to do this. There is a line of code within the below that says it can be done - I just don't know enough about VBA to do this. I found this code through You Tube so I was able to copy and paste to utilize the code but that is as far as my VBA skills go. Below is the video from YouTube. Any assistance you can provide would be very much appreciated.


https://youtu.be/IXvRQZw1Gps




Sub SaveMasterAs()


'Excel 10 Tutorial


Dim wb As Workbook


Dim rNames As Range, c As Range, r As Range


'Current file's list of names and ids on sheet1.


Set rNames = Worksheets("Sheet1").Range("A2", Worksheets("Sheet1").Range("A2").End(xlDown))


'Path and name to master workbook to open for copy, saveas.


Set wb = Workbooks.Open(ThisWorkbook.Path & "\PE Template.xlsx")


For Each c In rNames


With wb


'If You Need To Copy Something To the Template Use this line


'.Worksheets("Sheet1").Range("A1").Value = coffset.


'Path and name for copied workbook


.SaveAs Filename:=ThisWorkbook.Path & "\Template Copy\" & c.Value & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False


End With


Set wb = ActiveWorkbook


Next c


wb.Close


End Sub


1 Expert Answer

By:

Rize S. answered • 03/23/23

Tutor
New to Wyzant

Senior IT Certified Trainer, IT Developer & DBA Administrator

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.