I'm not a programmer but I have been working on this for a little but. I need to open the .txt file that is commas delimited. Delete columns A and column I. Save the file as the same name but a .csv. Close the file and open the next one in the same directory and repeat the process. I was worried if I opened them all first excel may crash.
Basically I can get the macro to do what I need it if I list out the file name, but there are thousands of files so I do not want to have to do that.
Here is my example without the loop (because I can not get the loop to successfully work)
I've been working to try to include something like this, but not being a programmer I'm not sure what i am doing and have not been successful yet.
Thanks in advance for an advice you may have to get be through this situation.
-Angel
Basically I can get the macro to do what I need it if I list out the file name, but there are thousands of files so I do not want to have to do that.
Here is my example without the loop (because I can not get the loop to successfully work)
Code:
Sub All()
Workbooks.OpenText Filename:= _
"C:\akm\1417.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlSingleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), _
Array(9, 1)), TrailingMinusNumbers:=True
Range("A:A,I:I").Select
Range("I1").Activate
Selection.Delete Shift:=xlToLeft
ActiveWorkbook.SaveAs Filename:= _
"C:\akm\1417.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
ActiveWindow.Close
End Sub
I've been working to try to include something like this, but not being a programmer I'm not sure what i am doing and have not been successful yet.
Code:
dim i as integer
dim maxnum as integer
dim filenamearray() as string
for i = 1 to maxnum
open( filenamearray(i) )
next i
Thanks in advance for an advice you may have to get be through this situation.
-Angel