+ Reply to Thread
Results 1 to 3 of 3

Copy a single file and rename based on cell value

  1. #1
    Registered User
    Join Date
    11-27-2019
    Location
    Vancouver
    MS-Off Ver
    Office 2013
    Posts
    2

    Copy a single file and rename based on cell value

    I have a folder that contains a master file, I like to copy it to a different folder and create new file names based on excel cell value.

    Master file --Different folder location ---create files based on cell value(john.pdf, mike.pdf and smith.pdf)

    The code I have below

    Sub CollectArt()
    Dim FSO As Object
    Dim SourceFileName, DestinFileFolder As String
    Dim rng As Range, cell As Range
    Set rng = Sheets("input").Range("Y2:Y100")

    Set FSO = CreateObject("Scripting.Filesystemobject")
    SourceFileName = "C:\Users\user\Desktop\template\master.pdf"
    For Each cell In rng
    If Len(cell) > 0 Then
    FSO.CopyFile Source:=SourceFileName, Destination:=DestinFileFolder

    DestinFileFolder = cell.Value

    Exit For
    End If
    Next cell


    End Sub

  2. #2
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Re: Copy a single file and rename based on cell value

    Try the following code

    new file name is value of Range A2

    Please Login or Register  to view this content.
    Last edited by saravnepali; 11-29-2019 at 07:37 PM.
    If you think someone helped you, click on the "* Add Reputation" as a way to say thank you.

    If your problem is solved, go to Thread Tools and select Mark This Thread Solved

  3. #3
    Registered User
    Join Date
    11-27-2019
    Location
    Vancouver
    MS-Off Ver
    Office 2013
    Posts
    2

    Re: Copy a single file and rename based on cell value

    I need to loop through Column A and rename by each individual cell value, any thought?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy-Hyperlink-Rename based on cell
    By jsherwood in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2018, 03:58 PM
  2. [SOLVED] Copy Row/Rename based on Cell Value
    By Betsy Simpkins in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-11-2017, 01:31 PM
  3. Copy paste and rename folder based on Cell values
    By BrettRogersUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2014, 04:54 AM
  4. Macro - Copy sheet and rename based on cell value
    By Nick.123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2013, 04:23 AM
  5. Rename cell based on file name for multiple files
    By lmolokin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2012, 05:49 PM
  6. Copy worksheet and rename based on cell range
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-08-2011, 06:53 AM
  7. Rename and save file to path based on cell info
    By cabinetguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2010, 12:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1