I have wrote a code which has browse dialog to select multiple files and save file names in array and loop them one by one perform action based on keyword in filename.
- as it has multi select option, I want to perform specific action based on keyword in filename
- am stuck in looping file names in array. I dkw where am going wrong
- correct my syntax if I wrong, bear with me as am very new to VBA
appreciate any help
fNameAndPath = Application.GetOpenFilename(fileFilter:="Excel Files (*.CSV), *.CSV", Title:="Select File To Be Opened", MultiSelect:=True) If Not IsArray(fNameAndPath) Then Exit Sub For Each MyFile In fNameAndPath Set wb = Workbooks.Open(MyFile)==========(how to search for specific file name in myfile array.. ' do stuff with workbook that has been opened if myfile= "*test_one*" then Set Fnd1 = Range("A1") Qty1 = WorksheetFunction.CountIf(Rows(1), "*shop3**high*") For Cnt1 = 1 To Qty1 Set Fnd1 = Rows(1).Find("*shop3**high*",Fnd1, , xlWhole, , , False, , False) max_num = Application.WorksheetFunction.Max(Fnd1.EntireColumn) ' maxnum value is copied to a cell in submit button Next Cnt1 elseif myfile="*test_last*" then 'similar to macro1 elseif myfile=test3.csv then similar to macro1 end if. wb.Close SaveChanges:=False Next MyFile End Sub