Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:21:43+00:00 2026-06-18T03:21:43+00:00

I’ve added an additional image to this. The DocType column is copied to this

  • 0

Cells to copy - creates a file path

I’ve added an additional image to this. The DocType column is copied to this sheet automatically from the “Doc Types” sheet. The content can change and range in how many cells are filled out. So formula creates first column, I need the vb to then evaluate the results of the File Path column and copy "C:\test\images\tester.TIF" how ever many times necessary to the file path that is created there. The code below that I currently have is much more simple but I have no idea which direction to go with this.

    Sub CopyEmTWO()
        Dim ws As Worksheet
        Dim strIn As String
        Dim strOut As String
        Dim strFile As String
        Dim strLPart As String
        Dim strRPart As String
        Dim lngCnt As String
        Dim lngFiles As Long
        Set ws = Sheets("MRT")
        lngCnt = Application.CountA(ws.Columns("A"))
        If lngCnt = 0 Then Exit Sub
        strIn = "C:\inserver6\script\Toolbelt\MRTesting\"
        strOut = "C:\inserver6\script\Toolbelt\MRTesting\"
        strFile = "MRTesting.tif"
        'extract string portions of the file name and type outside the copy loop
        strLPart = Left$(strFile, InStr(strFile, ".") - 1)
        strRPart = Right$(strFile, Len(strFile) - Len(strLPart))
        For lngFiles = 1 To lngCnt
            FileCopy strIn & strFile, strOut & strLPart & "(" & lngFiles & ")" & strRPart
        Next
    End Sub

I’m still a newbie and I’ve taken an 8 hour stab at this one and can’t get it right. Here is my working code for simply enumerating and duplicating. If it needs an entirely different approach please offer any ideas you have. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:21:44+00:00Added an answer on June 18, 2026 at 3:21 am

    If I understand the input correctly (screen was extremely helpful), the following piece of code will do the job:

    Sub CloneImage()
    
    Dim SampleFile As String
    Dim SampleFileExt As String
    Dim OutputFolder As String
    Dim ResultFile As String
    Dim CurrentName As String
    Dim FSO As Object
    Dim i As Long
    Dim CopyCount As Long
    
    SampleFile = "D:\DOCUMENTS\1.gif"
    OutputFolder = "D:\DOCUMENTS\1\"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    CopyCount = 0
    Application.ScreenUpdating = False
    
    If FSO.FileExists(SampleFile) = True Then
        SampleFileExt = "." & FSO.GetExtensionName(SampleFile)
    Else
        MsgBox "Source file:" & vbNewLine & SampleFile & vbNewLine & "does not exist!"
        Exit Sub
    End If
    
    If FSO.FolderExists(OutputFolder) = False Then FSO.CreateFolder OutputFolder
    
    For i = 2 To ThisWorkbook.ActiveSheet.Range("A1").CurrentRegion.Rows.Count
    
        CurrentName = ThisWorkbook.ActiveSheet.Cells(i, 1).Value
        ResultFile = OutputFolder & CurrentName & SampleFileExt
        ThisWorkbook.ActiveSheet.Cells(i, 2).Formula = ResultFile
        ThisWorkbook.ActiveSheet.Cells(i, 3).Formula = CurrentName & ": " & ResultFile
        If FSO.FileExists(ResultFile) = False Then
            FSO.CopyFile SampleFile, ResultFile
            CopyCount = CopyCount + 1
        Else
            MsgBox "Destination file:" & vbNewLine & ResultFile & vbNewLine & "already exists!"
        End If
    
    Next i
    
    ThisWorkbook.ActiveSheet.Range("A1").CurrentRegion.Columns.AutoFit
    
    Application.ScreenUpdating = True
    Set FSO = Nothing
    
    MsgBox i - 2 & " string(s) processed," & vbNewLine & CopyCount & " file(s) created in:" & vbNewLine & OutputFolder
    
    End Sub
    

    Assumptions & Limitations:

    1. Will warn about missing source file.
    2. File extension will be taken from the source.
    3. Output folder will be created automatically (if not exists).
    4. Will warn about already existing destination files.
    5. Final message with numbers of strings / files processed.

    Sample file is also shared: https://www.dropbox.com/s/jhbkwzuxzt01kzs/CloneImage.xlsm

    Hope that was helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.