Sub DISC_DUPLICATES_W_SUBCODE()
'
' DISC_DUPLICATES_W_SUBCODE Macro
'
'
Cells.Select
Cells.EntireColumn.AutoFit
Columns("K:K").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("J2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
Range("K25748").Select
ActiveCell.FormulaR1C1 = "X"
Selection.End(xlUp).Select
Range("K2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],C[-9],1,FALSE)"
Range("K2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$1:$T$35000").AutoFilter Field:=8, Criteria1:= _
"=DISCONTINUED", Operator:=xlAnd
ActiveSheet.Range("$A$1:$T$35000").AutoFilter Field:=11, Criteria1:=">=1", _
Operator:=xlAnd, Criteria2:="<=999999"
Rows("72:72").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
Cells.EntireColumn.AutoFit
Cells.Select
Cells.Select
Cells.EntireColumn.AutoFit
Cells.Select
ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
Add Key:=Range("A2:A34239"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
Add Key:=Range("H2:H34239"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort
.SetRange Range("A1:S34239")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B3").Select
ActiveCell.FormulaR1C1 = "=RC[-1]=R[-1]C[-1]"
Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.End(xlDown).Select
Range("B28797").Select
ActiveCell.FormulaR1C1 = "X"
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "FALSE"
Range("B1").Select
ActiveCell.FormulaR1C1 = "MATCH 1"
Columns("J:J").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(R[-1]C[-8]=""FALSE"",""FALSE"",IF(RC[-1]=""DISCONTINUED"",""TRUE""))"
Range("I2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.End(xlToRight).Select
Selection.End(xlToLeft).Select
Range("K2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range("J28797").Select
ActiveCell.FormulaR1C1 = "X"
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("J1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "MATCH 2"
Range("J2").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$U$34239").AutoFilter Field:=10, Criteria1:="=TRUE" _
, Operator:=xlAnd
Rows("69:69").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.AutoFilter
Cells.Select
ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort.SortFields. _
Add Key:=Range("A2:A34239"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("FW POG CONVERSION REFRESH FILE").Sort
.SetRange Range("A1:U34239")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Columns("I:I").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
End Sub
Bookmarks