Hello excel forum readers
I am making this thread to help me make some macros i am currently using,act in a row and add some features i couldn't establish
I will post the code of the macros too,maybe someone can find useful...who knows
1. First macro i am using to import a txt (they are all called "Inventory.txt)
2. Secondly i am using a macro to make an assortment (how it works excists in a thread in this forum)Sub TextImport()
myfile = Application.GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText Filename:=myfile _
, Origin:=1253, StartRow:=1, DataType:=xlFixedWidth, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(0, 2), Array(9, 2), Array(26, 1), Array(72, 1)), TrailingMinusNumbers:=True
Columns("A:A").ColumnWidth = 8.57
Columns("B:B").Select
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
End Sub
3.I am using a filter to delete the null cells in D ColumnPublic Sub CreateAggregates()
With Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp)).Offset(, 4)
.FormulaR1C1 = "=IF(COUNTIF(R1C2:RC2,""*""&MID(RC2,5,8)&""*"")=1,SUMIF(C2,""*""&MID(RC2,5,8)&""*"",C4),"""")"
.Offset(, -1).Value = .Value
.Clear
End With
End Sub
4. I am using this macro to make it possible to import this as a .txt in another programSub AutomaticFiltering()
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$E$156").AutoFilter Field:=4, Criteria1:="="
Rows("2:30000").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("F6").Select
End Sub
Sub KEFALAIO()
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Range("A1:A5257").Select
Selection.ClearContents
Range("A1").Select
ActiveCell.FormulaR1C1 = "23/07/2009 PARPF0001 01.001 "
Range("A2").Select
Columns("A:A").EntireColumn.AutoFit
End Sub
Now,what i want to do:
I want to choose the root file,and then it will search for the txts "Invetory.txt" in the folders in it
Use First macro to import them.
Use Second macro (the assortment thingy),and
Use Third macro (the automated filtering)
Then save it as an xls in the same file where the inventory comes.Now the tricky thing.In the file where the opened inventory.txt comes from,there is another xls (and it's the only one in the file).What i want is to take the name of this xls,add an ok next to it,and save it in the file as the name of the inventory.
Example,the inventory.txt will be saved like this,after the previous macros have be performed of course:excel 14ok.xls (because the exels in the file is named excel 14.xls)
Use Fourth Macro
This macro is a bit unfinished (though it works),what i mean:
In the line
ActiveCell.FormulaR1C1 = "23/07/2009 PARPF0014 01.001 "
I want to take dd/mm/yyyy from the system,and the (0014) is the number in the name of the file.xls this possible for them to be entered automatically?
Then copy the A1 cells according to the B column range
After this,if it's 99lines or less,save it with the name we took from excel.
If not pause and inform me because it's a bit complicated to explain and to be done with a macro.
It's important to start from where it stopped
Any help would be much appreciated
Thanks for reading my thread
Greetings alogoc
Bookmarks