mldaigle1
asked on
Excel Macro - Import
Hello Expert,
Below, the macro that i am using to import TXT file into my workbook, but now I only need your help to modify the macro so I will only import the TXT files that start by "ABC_". Can you help?
Below, the macro that i am using to import TXT file into my workbook, but now I only need your help to modify the macro so I will only import the TXT files that start by "ABC_". Can you help?
Sub TXTImporter()
Dim f As String, flPath As String
Dim i As Long, J As Long
Dim ws As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
flPath = ThisWorkbook.Path & Application.PathSeparator
i = ThisWorkbook.Worksheets.Count
J = Application.Workbooks.Count
f = Dir(flPath & "*.txt")
Do Until f = ""
Workbooks.OpenText flPath & f, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=False, Other:=False, TrailingMinusNumbers:=True
Workbooks(J + 1).Worksheets(1).Copy After:=ThisWorkbook.Worksheets(i)
ThisWorkbook.Worksheets(i + 1).Name = Left(f, Len(f) - 4)
Workbooks(J + 1).Close savechanges:=False
i = i + 1
f = Dir
Loop
Application.DisplayAlerts = True
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("Instructions").Select
Range("A4").Select
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks a lot and big kissDon't tell my wife:) Anyhow, you're welcome and I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
ASKER
So simple and I missed it!! I should not work on macro on friday afternoon. Well Martin, you're quick!
Thanks a lot and big kiss
(just wait my next question, won't be that easy...lol)