Hello everyone,
I need help with a VB coding I am trying to write for an excel file. Attached is the code:
Sub SCOMacro()
‘Delete sheet if already exists
On Error Resume Next
Application.DisplayAlerts = False
Sheets(“SCO Positions”).Delete
On Error GoTo 0
Application.DisplayAlerts = True
myfile = Application.GetOpenFilename
Workbooks.Open Filename:=myfile
Selection.AutoFilter Field:=1, Criteria1:=”804″
Selection.AutoFilter Field:=2, Criteria1:=”999″
Range(“A1”).Select
Selection.CurrentRegion.Select
Selection.Copy
Windows(“positions-Master file for Nov 05-Mary(copy).xls”).Activate
Sheets.Add
ActiveSheet.Paste
Range(“J1”).Select
Application.CutCopyMode = False
Selection.Copy
Range(“A1:U1”).Select
Selection.PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
Columns(“A:U”).Select
Columns(“A:U”).EntireColumn.AutoFit
ActiveSheet.Name = “SCO Positions”
Sheets(“SCO Positions”).Move after:=Sheets(“BCP PC-08 Positions”)
Range(“A1”).Select
End Sub
The problems I have are that the file choosen by the getfile command stays open and I need to close it. Also the Windows(“positions-Master file for Nov 05-Mary(copy).xls”).Activate can chance (for example next month will be Dec 05). Last, Once the macro is run, I would like to create another macro to do a sum for a column two rows below the last data information. Any help would be great. Thanks.