Hi all,
I would seek the kind help of members to suggest in simplifying this recorded macro
Thanks
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 02-10-2009 by ZOOM
'
' Keyboard Shortcut: Ctrl+a
'
Application.ScreenUpdating = False
ChDir "E:\Macros\Input"
Workbooks.Open Filename:="E:\Macros\Input\cm" & Format(Workbooks("NSE Converter.xls").Sheets("Sheet1").Range("G2").Value, "ddmmmyyyy") & "bhav.csv"
Columns("B:B").Select
Selection.Cut
Columns("L:L").Select
ActiveSheet.Paste
Columns("K:K").Select
Selection.Cut
Columns("B:B").Select
ActiveSheet.Paste
Selection.NumberFormat = "yyyymmdd"
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Range("A1:H1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=8, Criteria1:="=BE", Operator:=xlOr, _
Criteria2:="=EQ"
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveWindow.ScrollRow = 1
Range("I1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1:H1").Select
Selection.AutoFilter
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Range("B3").Select
Workbooks.OpenText Filename:="E:\Macros\Input\MTO_" & Format(Workbooks("NSE Converter.xls").Sheets("Sheet1").Range("G2").Value, "ddmmyyyy") & ".DAT", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
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)), TrailingMinusNumbers:=True
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Delete Shift:=xlToLeft
Columns("B:B").Select
Selection.Cut
Columns("D:D").Select
ActiveSheet.Paste
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Range("A1:C1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="EQ"
Range("A2:B2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("cm" & Format(Workbooks("NSE Converter.xls").Sheets("Sheet1").Range("G2").Value, "ddmmmyyyy") & "bhav.csv").Activate
Range("I1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("H1").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7],C[1]:C[2],2,0)"
Selection.Copy
Range("H2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("H:H").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("I:I").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Columns("H:H").Select
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\Stocks\cm" & Format(Date, "ddmmmyyyy") & "bhav.txt", FileFormat:=xlCSV _
, CreateBackup:=False
Application.DisplayAlerts = False
Application.ScreenUpdating = True
ActiveWindow.Close
ActiveWindow.Close
Application.ScreenUpdating = False
ChDir "E:\Macros\Input"
Workbooks.Open Filename:="E:\Macros\Input\fo" & Format(Workbooks("NSE Converter.xls").Sheets("Sheet1").Range("G2").Value, "ddmmmyyyy") & "bhav.csv", Origin:=xlWindows
I would seek the kind help of members to suggest in simplifying this recorded macro
Thanks