Uploaded by 30330098

new 13

advertisement
Sub Hybris_Magic_Compare()
Dim i As Long
Sheets("Magic").Select
For i = Cells(Rows.Count, 21).End(xlUp).Row To 2 Step -1
If Cells(i, 7) <> "6" Or IsNumeric(Cells(i, 13)) Or Cells(i, 21) = "30418" Then
Rows(i).Delete
End If
Next
Range("A:K").Sort key1:=[D1], order1:=xlAscending, Header:=xlYes
For i = 1 To 3
Range("A2").Select
Selection.EntireColumn.Delete
Next
For i = 1 To 4
Range("B2").Select
Selection.EntireColumn.Delete
Next
For i = 1 To 13
Range("D2").Select
Selection.EntireColumn.Delete
Next
Range("A2:C" & Cells(Cells.Rows.Count, 3).End(xlUp).Row).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Compare2").Select
Range("E2").Select
ActiveSheet.Paste
Sheets("Hybris").Select
For i = Cells(Rows.Count, 8).End(xlUp).Row To 2 Step -1
If Cells(i, 8) = "0" Or Cells(i, 2) = "" Then
Rows(i).Delete
End If
Next
Range("A:K").Sort key1:=[B1], order1:=xlAscending, Header:=xlYes
For i = 1 To 5
Range("C2").Select
Selection.EntireColumn.Delete
Next
For i = 1 To 2
Range("E2").Select
Selection.EntireColumn.Delete
Next
Range("A2:D" & Cells(Cells.Rows.Count, 4).End(xlUp).Row).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Compare1").Select
Range("A2").Select
ActiveSheet.Paste
Range("E2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-3],Magic!C[-4]:C[-2],1,0)"
Selection.AutoFill Destination:=Range("E2:E" & Cells(Rows.Count, 2).End(xlUp).Row)
Range("F2").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-4],Magic!C[-5]:C[-3],2,0),0)"
Selection.AutoFill Destination:=Range("F2:F" & Cells(Rows.Count, 2).End(xlUp).Row)
Range("G2").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-5],Magic!C[-6]:C[-4],3,0),0)"
Selection.AutoFill Destination:=Range("G2:G" & Cells(Rows.Count, 2).End(xlUp).Row)
Range("H2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]=-RC[-2]"
Selection.AutoFill Destination:=Range("H2:H" & Cells(Rows.Count, 2).End(xlUp).Row)
Range("I2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]=-RC[-2]"
Selection.AutoFill Destination:=Range("I2:I" & Cells(Rows.Count, 2).End(xlUp).Row)
Range("A:I").Sort key1:=[H1], order1:=xlAscending, Header:=xlYes
Sheets("Compare2").Select
Range("A2").Select
ActiveCell.FormulaR1C1 = "=INDEX(Hybris!C,MATCH(RC[4],Hybris!C[1],0))"
Selection.AutoFill Destination:=Range("A2:A" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("B2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[3],Hybris!C:C[2],1,0)"
Selection.AutoFill Destination:=Range("B2:B" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("C2").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[2],Hybris!C[-1]:C[1],2,0),0)"
Selection.AutoFill Destination:=Range("C2:C" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("D2").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[1],Hybris!C[-2]:C,3,0),0)"
Selection.AutoFill Destination:=Range("D2:D" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("H2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]=-RC[-2]"
Selection.AutoFill Destination:=Range("H2:H" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("I2").Select
ActiveCell.FormulaR1C1 = "=RC[-5]=-RC[-2]"
Selection.AutoFill Destination:=Range("I2:I" & Cells(Rows.Count, 5).End(xlUp).Row)
Range("A:I").Sort key1:=[H1], order1:=xlAscending, Header:=xlYes
End Sub
Download