Please paste code between code tags. Insert code tags by clicking the # icon on the toolbar of a reply.
You have several things that could be improved. First, you need to resolve the path issue. After running this, check VBE's Immediate window for found filenames if any. If the window is not in view, select the option in VBE's View menu.
Sub MergeWOrders()
Dim path As String, ThisWB As String, lngFilecounter As Long
Dim wbDest As Workbook, shtDest As Worksheet, ws As Worksheet
Dim Filename As String, Wkb As Workbook
Dim CopyRng As Range, Dest As Range
Dim RowofCopySheet As Long, glb_origCalculationMode As Integer
On Error GoTo EndSub
With Application
glb_origCalculationMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
.DisplayAlerts = False
.Cursor = xlWait
.StatusBar = "Processing Order files.."
.EnableCancelKey = xlErrorHandler
End With
path = Environ("USERPROFILE") & "\Downloads\orders\"
If Len(Dir(path, vbDirectory)) = 0 Then
path = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\" _
& "Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}"
With CreateObject("WScript.Shell")
path = .ExpandEnvironmentStrings(.RegRead(path) & "\orders\")
End With
End If
If Len(Dir(path, vbDirectory)) = 0 Then
MsgBox "Downloads\Orders path could not be found.", vbCritical, "Macro Ending"
GoTo EndSub
End If
Filename = Dir(path & "PO_Data*.xlsx", vbNormal)
If Len(Filename) = 0 Then
MsgBox "No PO_Data*.xlsx file could be found.", vbCritical, "Macro Ending"
GoTo EndSub
End If
Do Until Filename = vbNullString
Debug.Print Filename
Filename = Dir()
Loop
EndSub:
With Application
.Calculation = glb_origCalculationMode
.ScreenUpdating = True
.EnableEvents = True
.DisplayAlerts = True
.CalculateBeforeSave = True
.Cursor = xlDefault
.StatusBar = False
.EnableCancelKey = xlInterrupt
End With
End Sub