• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

need help with VBA


In the zone
I need a code in vba which would read a file name in a specified folder (dynamic path). the file name changes every time and there can be more than one files and the code should pick them all. The file is recognised by a word say "QWE" which exists in the file name everytime. e.g. E2 QWE T556M.XLSX etc... :???:


Aspiring Novelist
Sub Open_Files()
'//files are opened from here...and processed for raw data

Dim crnt_prj_pth As String
Dim fl_nm As String

fl_nm = Dir(crnt_prj_pth & "\" & "*.CSV") '//.CSV wildcard is being used here

Do While fl_nm <> "" '//master LOOP

'//intermediate processing

fl_nm = Dir


End Sub

This will cycle through the directory path which you assign to the variable "crnt_prj_pth".
Top Bottom