Macro for copying the file

I am working on another piece of work, and I am relatively new at this.

Private Sub Copy()
Dim lastrow As Integer
Dim count As Integer
Dim salespersonname As String
Dim destinationfile As Variant
Dim sourcefile As Variant
Dim drive As Variant
Dim extension As Variant
Dim row As String

Range(“a1”).Select
drive = “C:UsersPublicDocumentsTest Excel” ‘enter full path preceding name
extension = “.xlsx” ‘replace extension with what you require
lastrow = Range(“b1”).Value
sourcefile = “C:UsersPublicDocumentsTest ExcelFinal_tool.xlsx” ‘replace this with the file you want to copy

For count = 1 To lastrow
row = “a” & count
Range(
).Select
Salespersonname = ActiveCell.Value
destinationfile = drive & Salespersonname & extension
FileCopy sourcefile, destinationfile
Next count

End Sub
This code for creating multiple copies of a workbook and names to be saved based on the names given in the column a. When I am executing this code, this is not working. Can someone please help me out here?

By: MY

Leave a Reply

Your email address will not be published. Required fields are marked *