Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following macro that needs to be cleaned up a bit (part of
the code was generated using the macro recorder; this is the stuff that I think needs to be cleaned up. Following is the code: Option Explicit Sub ParseELR() 'Parses the ELR report, filters it, copies the filtered records, pastes them into a new workbook 'and prompts the user to save the file to a specific location Dim myFileName As Variant Range("A3").Select If ActiveSheet.AutoFilterMode = True Then ActiveSheet.ShowAllData End If Range("T2").Select ActiveCell.FormulaR1C1 = "=IF(AND(ISNUMBER(MATCH(LEFT(RC[-18], 3),'[ELR expense account identification.xls]Sheet1'! R2C1:R12C1,0)),ISNUMBER(MATCH(RC[-17],'[Frank''s expense codes--GDCS and non-GDCS.xls]Sheet1'!R2C1:R39C1,0))),""Extract"","""")" 'Applies the filter criteria to each row; if BOTH conditions return TRUE, "Extract" is returned in Column T 'THIS IS THE SECTION THAT NEEDS TO BE CLEANED UP Range("T2:T65000").Select Selection.FillDown Selection.End(xlUp).Select Selection.AutoFilter Field:=20, Criteria1:="Extract" 'Runs autofilter on the value "extract" in Column T Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.SpecialCells(xlCellTypeVisible).Select Selection.Copy Workbooks.Add ActiveSheet.Paste Application.CutCopyMode = False 'END SECTION THAT NEEDS TO BE CLEANED UP myFileName = Application.GetSaveAsFilename If myFileName = False Then Exit Sub End If ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal End Sub Thanks, Dave |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
clean up code a little | Excel Discussion (Misc queries) | |||
Clean up code. | Excel Programming | |||
Help clean up this code... | Excel Programming | |||
Clean up code using WITHs | Excel Programming | |||
Plase help me clean up my code | Excel Programming |