spectraflame
Well-known Member
- Joined
- Dec 18, 2002
- Messages
- 830
- Office Version
- 365
- Platform
- Windows
Does anyone have any suggestions on how to improve the speed of this macro? The ELECTRIC_MXU_REPORT sheet contains about 9,400 rows. The rest of the Sheets referenced in the macro contain 10,000 rows or less.
Sub COMBINE_ALL_DATA()
Application.ScreenUpdating = False
MsgBox "This process could take up to 3 minutes to complete."
Sheets("ELECTRIC_MXU_REPORT").Select
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Range("H1").Select
ActiveCell.FormulaR1C1 = "TYPE"
Range("I1").Select
ActiveCell.FormulaR1C1 = "SIZE"
Range("J1").Select
ActiveCell.FormulaR1C1 = "CLASS"
Range("K1").Select
ActiveCell.FormulaR1C1 = "SCALE"
Range("L1").Select
ActiveCell.FormulaR1C1 = "STATUS"
Range("M1").Select
ActiveCell.FormulaR1C1 = "TESTED"
Range("H1:M1").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-5],INCODE_METER_DATA,5,0)),0,VLOOKUP(RC[-5],INCODE_METER_DATA,5,0))"
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-6],INCODE_METER_DATA,6,0)),0,VLOOKUP(RC[-6],INCODE_METER_DATA,6,0))"
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-6],INCODE_MASTER_DATA,3,0)),0,VLOOKUP(RC[-6],INCODE_MASTER_DATA,3,0))"
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-8],SCALE_FACTOR,5,0)),0,VLOOKUP(RC[-8],SCALE_FACTOR,5,0))"
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-8],INCODE_MASTER_DATA,4,0)),0,VLOOKUP(RC[-8],INCODE_MASTER_DATA,4,0))"
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(INDEX(ELECTRIC_METER_REPORT!C[-5],MATCH(ELECTRIC_MXU_REPORT!RC[-10],ELECTRIC_METER_REPORT!C[-11],0)+1)=0,"""",INDEX(ELECTRIC_METER_REPORT!C[-5],MATCH(ELECTRIC_MXU_REPORT!RC[-10],ELECTRIC_METER_REPORT!C[-11],0)+1))"
LR = ActiveSheet.UsedRange.Rows.Count
Range("H2").AutoFill Destination:=Range("H2:H" & LR)
Range("I2").AutoFill Destination:=Range("I2:I" & LR)
Range("J2").AutoFill Destination:=Range("J2:J" & LR)
Range("K2").AutoFill Destination:=Range("K2:K" & LR)
Range("L2").AutoFill Destination:=Range("L2:L" & LR)
Range("M2").AutoFill Destination:=Range("M2:M" & LR)
Columns("M:M").Select
Selection.NumberFormat = "mm/dd/yy"
Columns("H:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("H1:M1").Select
Columns("H:M").EntireColumn.AutoFit
Range("A2").Select
Application.ScreenUpdating = True
End Sub
Sub COMBINE_ALL_DATA()
Application.ScreenUpdating = False
MsgBox "This process could take up to 3 minutes to complete."
Sheets("ELECTRIC_MXU_REPORT").Select
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Range("H1").Select
ActiveCell.FormulaR1C1 = "TYPE"
Range("I1").Select
ActiveCell.FormulaR1C1 = "SIZE"
Range("J1").Select
ActiveCell.FormulaR1C1 = "CLASS"
Range("K1").Select
ActiveCell.FormulaR1C1 = "SCALE"
Range("L1").Select
ActiveCell.FormulaR1C1 = "STATUS"
Range("M1").Select
ActiveCell.FormulaR1C1 = "TESTED"
Range("H1:M1").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-5],INCODE_METER_DATA,5,0)),0,VLOOKUP(RC[-5],INCODE_METER_DATA,5,0))"
Range("I2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-6],INCODE_METER_DATA,6,0)),0,VLOOKUP(RC[-6],INCODE_METER_DATA,6,0))"
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-6],INCODE_MASTER_DATA,3,0)),0,VLOOKUP(RC[-6],INCODE_MASTER_DATA,3,0))"
Range("K2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-8],SCALE_FACTOR,5,0)),0,VLOOKUP(RC[-8],SCALE_FACTOR,5,0))"
Range("L2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-8],INCODE_MASTER_DATA,4,0)),0,VLOOKUP(RC[-8],INCODE_MASTER_DATA,4,0))"
Range("M2").Select
ActiveCell.FormulaR1C1 = _
"=IF(INDEX(ELECTRIC_METER_REPORT!C[-5],MATCH(ELECTRIC_MXU_REPORT!RC[-10],ELECTRIC_METER_REPORT!C[-11],0)+1)=0,"""",INDEX(ELECTRIC_METER_REPORT!C[-5],MATCH(ELECTRIC_MXU_REPORT!RC[-10],ELECTRIC_METER_REPORT!C[-11],0)+1))"
LR = ActiveSheet.UsedRange.Rows.Count
Range("H2").AutoFill Destination:=Range("H2:H" & LR)
Range("I2").AutoFill Destination:=Range("I2:I" & LR)
Range("J2").AutoFill Destination:=Range("J2:J" & LR)
Range("K2").AutoFill Destination:=Range("K2:K" & LR)
Range("L2").AutoFill Destination:=Range("L2:L" & LR)
Range("M2").AutoFill Destination:=Range("M2:M" & LR)
Columns("M:M").Select
Selection.NumberFormat = "mm/dd/yy"
Columns("H:M").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Range("H1:M1").Select
Columns("H:M").EntireColumn.AutoFit
Range("A2").Select
Application.ScreenUpdating = True
End Sub