0
Sub CheckandSend()
    Dim strfile As String
    Dim ws As Worksheet 'make sure to define a sheet
    Set ws = ThisWorkbook.Worksheets("RFQ")
    Sheets("Part list").Select
    Sheets("RFQ").Select
    Dim lastrow As Long
    lastrow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
    Range("A6:E" & lastrow).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Part list").Select
    Cells.Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Cells.Select
    Cells.EntireColumn.AutoFit
Dim Worksheet2_Name As String
WorkRFQ_Name = "Part list" ' Replace this with the name of the first sheet you want to export
Set WorkRFQ = ThisWorkbook.Worksheets(WorkRFQ_Name)
Dim Write_Directory As String
Dim WorkRFQ_Path As String
Write_Directory = "P:\CENTRAL\PROJECTS\TARSON\Newfolder1\" 
WorkRFQ_Path = Write_Directory & "\" & WorkRFQ_Name
WorkRFQ.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    FileName:=WorkRFQ_Path, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False
    
    Sheets("Part list").Select
    Columns("A:Z").Select
    Selection.Delete
    Sheets("RFQ").Select
    Dim SourcePath As String
    SourcePath = "I:\Mechanical\External\Emission\35Test Rig\1Vendor\"
    Dim DestPath As String
    DestPath = "P:\CENTRAL\PROJECTS\TARSON\Newfolder1\" 

    Dim irow As Long
    Dim f As SearchFolders
    Dim filetype As String
    filetype = "*.pdf"
    irow = 7
    
    Do While ws.Cells(irow, 2) <> vbNullString
        Dim FileName As String
        FileName = Dir(SourcePath & ws.Cells(irow, 2) & "*.pdf")
       
        Do While FileName <> vbNullString
            VBA.FileCopy SourcePath & FileName, DestPath & FileName
            FileName = Dir()
        Loop
        
        irow = irow + 1
    Loop
end sub

On here, this code is help me to find an pdf file which is present in my sourcepath & plug that file & place in my destpath now where i am lagging is, in my sourcepath (pdf to vendor") after this folder there are multiple sub-folders , i want a code which loop through all sub-folders and find my files and place it in my dest path

my sub folders will be look like OP10, OP20, OP30.....ETC...,

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 3
    Answered at your previous posting of this question - https://stackoverflow.com/questions/66684399/loop-through-sub-dir – Tim Williams Mar 23 '21 at 03:45
  • 1
    Does this answer your question? [Loop Through Sub-Dir](https://stackoverflow.com/questions/66684399/loop-through-sub-dir) – Jason Harrison Mar 23 '21 at 20:42
  • No, i cant understand the logic , can u plwase explain that ? – MBA - Design 1 Mar 24 '21 at 08:37
  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ Mar 25 '21 at 07:03

0 Answers0