COPY FILES MACRO

  • Hi,


    i want to copy the list of files from A column and below macro was copied but it was not looping to copied command, can any one help me....



    Range is "Column A" and Msg box is "Column B" Format types .doc, .rtf,.docx , .pdf


    Please anyone help me in this regards or if possible make it as easier to loop and thanks in advance.



    <img src="https://www.ozgrid.com/forum/core/images/smilies/emojione/263a.png" alt=":)" class="smiley" srcset="https://www.ozgrid.com/forum/core/images/smilies/emojione/[email protected] 2x" height="23" data-tooltip="smile" id="wscSmiley_0_0">




    Code
    1. Range is "Column A" and Msg box is "Column B" Format types .doc, .rtf,.docx , .pdf
    2. Please anyone help me in this regards or if possible make it as easier to loop and thanks in advance.
    3. <img src="https://www.ozgrid.com/forum/core/images/smilies/emojione/263a.png" alt=":)" class="smiley" srcset="https://www.ozgrid.com/forum/core/images/smilies/emojione/[email protected] 2x" height="23" data-tooltip="smile" id="wscSmiley_0_0">
  • Macro was running properly but not copying the files listed in A column but not giving any error message i think it was not looping here ....


    Can you please help me.......

    1. objFSO.CopyFile Source:=SourcePath & Range("B" & CStr(iRow)).Value & _
    2. sFileType, Destination:=DestinationPath
  • If i got your code for good and i thing everything is ok except some chanages i hv made.

    Take a look and if you want something else plz let me know.

    Regards

  • Hi,


    Thanks for replying but i tried on the code still it is not copying the files from source to destination based on the excel value.

    Comment should be provided whether it has copied or not in column B

    Am sharing screenshot as "Not working" and "Required outout (actual output)"


    PFA


    Can you pleas review once and am very thankful to you......

  • Xm.. Οκ

    Plz send me the whole Function Code and your References Settings (its under Tools Tab) as my pic .

    Is it possible ?


    end

  • Hi,


    Please check once....




    Please see the above ....


    Settings are the same...

  • Check the Attachment

    The are two Functions

    Sub CopyFiles() This is mine

    Sub CopyFiles1() This is Yours BUT I replaced the B: with A: in



    Code
    1. If Len(Dir(SourcePath & Range("A" & CStr(iRow)).Value & sFileType)) = 0 Then
    2. Range("B" & CStr(iRow)).Value = "Does Not Exists"
    3. Range("B" & CStr(iRow)).Font.Bold = True
    4. Else
    5. Range("B" & CStr(iRow)).Value = "Copied"
    6. Range("B" & CStr(iRow)).Font.Bold = False
    7. Plz at the End of your Code (After the Wend ) and the command :
    8. Set objFSO = Nothing


    Hope be Ok Now




    Regards

  • Hi


    Am very very thankful to your hard and code was still not copying the files if it exits in my machine...


    I tried a lot but still not working both code and macro was running successfully with out throwing any errors but output folder was always empty ...


    Thank you so much....


    If you have time you can review or else skip this, it might be my excel problem and am very thankful to for your propmt response .....


    Once again Thank You................

  • We will fixit !

    Dont worry

    tomorrow morning

  • I've looked at your code and it seems like you need a list of files in the sheet.


    Relying on InputBoxes for the file paths is open to input error though. Not fully tested but let me know if it's better.


  • Hi,


    Thank you for replying ....


    Sorry for inconvenience caused to you, now am attaching the same files in the ZIP folder.

    Please review once and code was running successfully but copying the files into the folder and showing message as "Does not exits" even if it having a same file in the folder.


    Thanks in advance for your consideration.................

  • Hello

    Yes !! you need the full path

    Is it Ok now ?