Every month i get a billing record of roughly 5,000 lines in whats called a flat file. within the 5,000+ lines there are multiple billing types (read billable services). So example. Customer A could have 18 different bill types and customer B could have 25.
Each bill type has 2 lines, a header line and a data line. and each bill type has different headers and the number of columns. Except for the 1st 3 which is always customer number, date, record type(bill type). in addition each bill type will need to have their own worksheet.
So here's what I've done.
Sub BillType2()
'Clearing the destination worksheet of previous data
Sheets("REC_type_2_summary").Activate
Rows("2:2").Select
Selection.AutoFilter
Range("B3:I3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Clear
'back to source file
Sheets("CGT_REPORT (3)").Activate
Rows("1:1").Select
Application.CutCopyMode = False
Selection.AutoFilter
'setting filter for record type and eliminating the header rows.
ActiveSheet.Range("$A$1:$AL$14637").AutoFilter Field:=3, Criteria1:="2"
ActiveSheet.Range("$A$1:$AL$14637").AutoFilter Field:=4, Criteria1:="<>*Exhibit*"
Range("A2:H2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
'Pasting result back to the destination sheet for that record type
Sheets("REC_type_2_summary").Activate
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns(3).NumberFormat = "mm/dd/yy"
Range("C1").NumberFormat = "###"
If Range("C1") > 0 Then
Rows("2:2").Select
Selection.AutoFilter Field:=10, Criteria1:="<>0"
End If
End Sub
Now I do a similar process with about 35 other bill types, each with just slightly different criterias. then i put them all together in one large macro called runAll which is just basically me calling all 35 macros.
70% of the time it runs fine. however other times it either takes for ever or i'll get the error that shows I'm running out of resources. How to make this more efficient?