excel - How do I add a custom search filter to my method? -


I am writing a macro that involves taking .csv files from folders. The macro asks the user to enter the folder path and when it is entered, it will take all the .csv files in the folder and sheet them in the workbook.

I want the macro to ask the user what extension they want in the workbook.

For example, some files have names like Chan_41-103.csv, Chan_41-109.csv, and Chan_44-103.csv. So if there is a way to ask the user what they want and they can enter "* -103.csv" and the files in the macro file name with -103.csv.

I know that I can do the straightforward code "* -103.csv" and it will do this, but there are so many files with different names and I want to give this macro to a group of files Will have to run for. If it can ask the user, then it would be great.

There is already code at:

  sub CSV_Sheets () 'from this one The csv file takes the specific folder and it's string cell (2, 2). In the form of a string dimension in the form of slow I as integer slow path in the workbook. Value = input box ("extension of file:", "extension * - # .csv") extension = cell (2, 2). Value & amp; "\" I = 1 range ("A1") value = "CSV folder path =" range ("A1"). Horizontal alignment = XL right cell (1, 2). Value = input box ("CSV file folder path:", "path assignment") path = cell (1, 2). Value & amp; "\" File name = Dir (path and extension) while filename & lt; & Gt; "" Workbook Open file name: = Path & amp; File name, readline: = true for ActiveWorkbook.Sheets sheet in each work sheet. After Cop: = ThisWorkbook.Sheets (1) Next sheet workbooks (filename) .file name = Dir () Loop ending sub    

  sub test () Dim FolderPath as string dim XLVB excel. The workbook dim file name string as the dim path in the form of a string folder path = "PathToYourFolder" path = folderpath & amp; "\ *" & Amp; InputBox ("Enter extensions here.", "Extension recovery") & amp; ".ccv" filename = Dir (path) if file name = "" then alsef filename & lt; & Gt; "Set" xlwb = Excel.Workbooks.Open (FolderPath & amp; "\" and file name) End if end   

acts as a starter wildcard, I It tested with a file named test-104.csv and it worked like a magic

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -