Good Evening to everyone..
I have recorded a macro code...but it is taking lot of time for getting the output..Can anyone help me to tweak my code..by cleaning the unnecessary lines to execute the code more quickly
Thank u
I have recorded a macro code...but it is taking lot of time for getting the output..Can anyone help me to tweak my code..by cleaning the unnecessary lines to execute the code more quickly
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/04/2011 by ABS
'
' Keyboard Shortcut: Ctrl+a
'
ChDir "E:\Macros\Input"
Workbooks.Open Filename:="E:\Macros\Input\c.csv"
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="=ET", Operator:=xlOr, _
Criteria2:="=BT"
Range("B:B,G:G,H:H,J:J").Select
Range("J1").Activate
Selection.AutoFilter Field:=2
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Cut
Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Selection.NumberFormat = "yyyymmdd"
Rows("1:1").Select
Selection.Delete Shift:=xlUp
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;E:\Macros\Input\m.DAT", Destination:=Range("A1"))
.Name = "MTO_04012010"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A:A,B:B,E:E,G:G").Select
Range("G1").Activate
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="=ET", Operator:=xlOr, _
Criteria2:="=BE"
Sheets("c").Select
Range("H1").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7],Sheet1!C[-7]:C[-5],3,0)"
Range("H1").Select
Selection.AutoFill Destination:=Range("H1:H1333")
Range("H1:H1333").Select
Range("H1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Replace What:="#N/A", Replacement:="0", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
ChDir "E:\Macros\Output"
ActiveWorkbook.SaveAs Filename:="E:\Macros\Output\c.csv", _
FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWindow.Close
ActiveWindow.Close
End Sub