Hi all,
I saw another thread on the same topic but I am not able to reuse the information provided before.
I am trying to reduce the size of my file and to speedup my macro which contain a huge dirty Vlookup
I know its an ugly macro but cant get my head around, need some helps
Thanks in advance
Here the Macro:
Sheets("MasterData").Select
Range("AH9").Select
Range(Selection, Range("AH65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("L9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("MasterData").Select
Range("AI9").Select
Range(Selection, Range("AI65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("N9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("MasterData").Select
Range("AJ9").Select
Range(Selection, Range("AJ65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("O9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Apply formulas
Sheets("CalcData").Select
Range("C9").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(C[-2],InventoryReport!C[-1]:C[1],3,0),0)"
Range("C9").Select
Selection.AutoFill Destination:=Range("C9:C" & Range("A9").End(xlDown).Row)
Range("C9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("C9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("CalcData").Select
Range("D9").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(C[-3],InventoryReport!C[-2]:C[2],5,0),0)"
Range("D9").Select
Selection.AutoFill Destination:=Range("D9:D" & Range("A9").End(xlDown).Row)
Range("D9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("S9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(VLOOKUP(C1,MouvementReport!C1:C107,CalcData!R7C[3],0),0)"
Range("S9").Select
Selection.AutoFill Destination:=Range("S9:BR9"), Type:=xlFillDefault
Range("S9:BR9").Select
Selection.AutoFill Destination:=Range("S9:BR" & Range("A9").End(xlDown).Row)
Range("S9:BR9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("S9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("BT9").Select
ActiveCell.FormulaR1C1 = "=+IFERROR(VLOOKUP(C71,Code!R1C1:R5C2,2,0),0)"
Range("BT9").Select
Selection.AutoFill Destination:=Range("BT9:BT" & Range("A9").End(xlDown).Row)
Range("BT9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("BT9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("BW9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(STDEVP(RC[-56]:RC[-5])/AVERAGE(RC[-56]:RC[-5]),0)"
Range("BX9").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=0,""Z"",IF(RC[-1]<=1,""L"",IF(RC[-1]>3,""H"",""M"")))"
Range("BY9").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""Z"",""DZ"",CONCATENATE(RC[-67],RC[-1]))"
Range("BZ9").Select
ActiveCell.FormulaR1C1 = _
"=+IF(RC[-1]=""DZ"","""",VLOOKUP(RC[-1],Code!R9C1:R17C2,2,0))"
Range("CA9").Select
ActiveCell.FormulaR1C1 = _
"=+IF(RC[-2]=""DZ"","""",VLOOKUP(RC[-2],Code!R9C1:R17C3,3,0))"
Range("CB9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(STDEVP(RC[-61]:RC[-10])*NORMSINV(RC[-2])*SQRT((RC[-67]/7)),0)"
Range("CC9").Select
ActiveCell.FormulaR1C1 = "=+IFERROR(RC[-1]*365/SUM(RC[-62]:RC[-11]),0)"
Range("BW9:CC9").Select
Selection.AutoFill Destination:=Range("BW9:CC" & Range("A9").End(xlDown).Row)
Range("BW9:CC9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("BW9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
I saw another thread on the same topic but I am not able to reuse the information provided before.
I am trying to reduce the size of my file and to speedup my macro which contain a huge dirty Vlookup
I know its an ugly macro but cant get my head around, need some helps
Thanks in advance
Here the Macro:
Sheets("MasterData").Select
Range("AH9").Select
Range(Selection, Range("AH65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("L9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("MasterData").Select
Range("AI9").Select
Range(Selection, Range("AI65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("N9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("MasterData").Select
Range("AJ9").Select
Range(Selection, Range("AJ65536").End(xlUp)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("CalcData").Select
Range("O9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
' Apply formulas
Sheets("CalcData").Select
Range("C9").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(C[-2],InventoryReport!C[-1]:C[1],3,0),0)"
Range("C9").Select
Selection.AutoFill Destination:=Range("C9:C" & Range("A9").End(xlDown).Row)
Range("C9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("C9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("CalcData").Select
Range("D9").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(C[-3],InventoryReport!C[-2]:C[2],5,0),0)"
Range("D9").Select
Selection.AutoFill Destination:=Range("D9:D" & Range("A9").End(xlDown).Row)
Range("D9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("D9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("S9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(VLOOKUP(C1,MouvementReport!C1:C107,CalcData!R7C[3],0),0)"
Range("S9").Select
Selection.AutoFill Destination:=Range("S9:BR9"), Type:=xlFillDefault
Range("S9:BR9").Select
Selection.AutoFill Destination:=Range("S9:BR" & Range("A9").End(xlDown).Row)
Range("S9:BR9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("S9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("BT9").Select
ActiveCell.FormulaR1C1 = "=+IFERROR(VLOOKUP(C71,Code!R1C1:R5C2,2,0),0)"
Range("BT9").Select
Selection.AutoFill Destination:=Range("BT9:BT" & Range("A9").End(xlDown).Row)
Range("BT9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("BT9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("BW9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(STDEVP(RC[-56]:RC[-5])/AVERAGE(RC[-56]:RC[-5]),0)"
Range("BX9").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=0,""Z"",IF(RC[-1]<=1,""L"",IF(RC[-1]>3,""H"",""M"")))"
Range("BY9").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""Z"",""DZ"",CONCATENATE(RC[-67],RC[-1]))"
Range("BZ9").Select
ActiveCell.FormulaR1C1 = _
"=+IF(RC[-1]=""DZ"","""",VLOOKUP(RC[-1],Code!R9C1:R17C2,2,0))"
Range("CA9").Select
ActiveCell.FormulaR1C1 = _
"=+IF(RC[-2]=""DZ"","""",VLOOKUP(RC[-2],Code!R9C1:R17C3,3,0))"
Range("CB9").Select
ActiveCell.FormulaR1C1 = _
"=+IFERROR(STDEVP(RC[-61]:RC[-10])*NORMSINV(RC[-2])*SQRT((RC[-67]/7)),0)"
Range("CC9").Select
ActiveCell.FormulaR1C1 = "=+IFERROR(RC[-1]*365/SUM(RC[-62]:RC[-11]),0)"
Range("BW9:CC9").Select
Selection.AutoFill Destination:=Range("BW9:CC" & Range("A9").End(xlDown).Row)
Range("BW9:CC9").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("BW9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False