Sub Copy_From()
'
' Copy_From Macro
'
'
Dim Rij, TIO As Worksheet
Set TIO = Sheets("Total_Item_Overview")
With Sheets("create New item") 'dat werkblad
If Len(.Range("D8")) = 0 Then Exit Sub ' er staat niets in D8 = stoppen
Rij = Application.Match(.Range("D8").Value, TIO.Range("A1:A" & TIO.Range("A" & Rows.Count).End(xlUp).Row), 0) ' zoek rijnummer van dat
If Not (IsNumeric(Rij)) Then MsgBox " onbekend SAP nummer " & .Range("D8").Value, vbCritical: End 'onbekend SAP-nummer
.Range("D9").Value = TIO.Cells(Rij, 3).Value 'staat in TIO in die rij, de 3e kolom
.Range("H8").Value = TIO.Cells(Rij, 14).Value
'op deze manier alle cellen aanpassen met de juiste kolom
Range("H9").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-1]C4,Total_item_overview!R2C[-7]:R100000C[70],15,FALSE))"
Range("H10").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-2]C4,Total_item_overview!R2C[-7]:R100000C[70],16,FALSE))"
Range("H11").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-3]C4,Total_item_overview!R2C[-7]:R100000C[70],17,FALSE))"
Range("H12").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-4]C4,Total_item_overview!R2C[-7]:R100000C[70],36,FALSE))"
Range("H13").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-5]C4,Total_item_overview!R2C[-7]:R100000C[70],37,FALSE))"
Range("H14").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-6]C4,Total_item_overview!R2C[-7]:R100000C[70],38,FALSE))"
Range("H15").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-7]C4,Total_item_overview!R2C[-7]:R100000C[70],39,FALSE))"
Range("H16").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-8]C4,Total_item_overview!R2C[-7]:R100000C[70],40,FALSE))"
Range("H17").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-9]C4,Total_item_overview!R2C[-7]:R100000C[70],41,FALSE))"
Range("H18").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-10]C4,Total_item_overview!R2C[-7]:R100000C[70],42,FALSE))"
Range("L7").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[1]C4,Total_item_overview!R2C[-11]:R100000C[66],18,FALSE))"
Range("L8").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(RC4,Total_item_overview!R2C[-11]:R100000C[66],19,FALSE))"
Range("L9").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-1]C4,Total_item_overview!R2C[-11]:R100000C[66],20,FALSE))"
Range("L10").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-2]C4,Total_item_overview!R2C[-11]:R100000C[66],21,FALSE))"
Range("L11").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-3]C4,Total_item_overview!R2C[-11]:R100000C[66],22,FALSE))"
Range("L12").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-4]C4,Total_item_overview!R2C[-11]:R100000C[66],26,FALSE))"
Range("L13").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-5]C4,Total_item_overview!R2C[-11]:R100000C[66],29,FALSE))"
Range("L14").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-6]C4,Total_item_overview!R2C[-11]:R100000C[66],43,FALSE))"
Range("L15").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-7]C4,Total_item_overview!R2C[-11]:R100000C[66],44,FALSE))"
Range("L16").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-8]C4,Total_item_overview!R2C[-11]:R100000C[66],55,FALSE))"
Range("D21").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-13]C4,Total_item_overview!R2C[-3]:R100000C[51],4,FALSE))"
Range("D22").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-14]C4,Total_item_overview!R2C[-3]:R100000C[51],5,FALSE))"
Range("D23").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-15]C4,Total_item_overview!R2C[-3]:R100000C[51],6,FALSE))"
Range("D24").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-16]C4,Total_item_overview!R2C[-3]:R100000C[51],7,FALSE))"
Range("D25").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-17]C4,Total_item_overview!R2C[-3]:R100000C[51],8,FALSE))"
Range("D26").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-18]C4,Total_item_overview!R2C[-3]:R100000C[51],9,FALSE))"
Range("D27").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-19]C4,Total_item_overview!R2C[-3]:R100000C[51],10,FALSE))"
Range("D28").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-20]C4,Total_item_overview!R2C[-3]:R100000C[51],11,FALSE))"
Range("D29").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-21]C4,Total_item_overview!R2C[-3]:R100000C[51],12,FALSE))"
Range("D30").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-22]C4,Total_item_overview!R2C[-3]:R100000C[51],13,FALSE))"
Range("L22").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-14]C4,Total_item_overview!R2C[-11]:R100000C[66],45,FALSE))"
Range("L25").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",IFERROR(((((R12C12*R51C4)/100)-R50C4)/R11C12),""N.A.""))"
Range("L27").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-19]C4,Total_item_overview!R2C[-11]:R100000C[66],56,FALSE))"
Range("L28").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-20]C4,Total_item_overview!R2C[-11]:R100000C[66],16,FALSE))"
Range("L29").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C12='Masterdata info'!R2C25,""0070"",IF(R43C12='Masterdata info'!R3C25,""0105"",IF(R43C12='Masterdata info'!R4C25,""0106"",IF(R43C12='Masterdata info'!R5C25,""0070"",""""))))"
Range("L30").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-22]C4,Total_item_overview!R2C[-11]:R100000C[66],47,FALSE))"
Range("L31").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",IF(R12C12="""","""",IF(R29C12=106,VLOOKUP(MATCH(R12C12,LIJST_LIFO,1),Tabel0106,3,FALSE),VLOOKUP(MATCH(R12C12,LIJST_FIFO,1),Tabel0105,3,FALSE))))"
Range("N31").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",IF(R31C12=""N.A"",""N.A"",IF(R31C12="""","""",IF(R29C12=106,VLOOKUP(R31C12,'Masterdata info'!R3C3:R11C4,2,FALSE),VLOOKUP(R31C12,'Masterdata info'!R3C8:R11C9,2,FALSE)))))"
Range("L32").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-24]C4,Total_item_overview!R2C[-11]:R100000C[66],48,FALSE))"
Range("L33").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-25]C4,Total_item_overview!R2C[-11]:R100000C[66],49,FALSE))"
Range("L34").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-26]C4,Total_item_overview!R2C[-11]:R100000C[66],60,FALSE))"
Range("L35").Select
ActiveWindow.SmallScroll Down:=18
Range("E37").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-29]C4,Total_item_overview!R2C[-4]:R100000C[73],52,FALSE))"
Range("E38").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-30]C4,Total_item_overview!R2C[-4]:R100000C[73],53,FALSE))"
Range("E39").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-31]C4,Total_item_overview!R2C[-4]:R100000C[73],54,FALSE))"
Range("L37").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-29]C4,Total_item_overview!R2C[-11]:R100000C[66],57,FALSE))"
Range("L38").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-30]C4,Total_item_overview!R2C[-11]:R100000C[66],58,FALSE))"
Range("L39").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-31]C4,Total_item_overview!R2C[-11]:R100000C[66],59,FALSE))"
Range("D43").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-35]C4,Total_item_overview!R2C[-3]:R100000C[74],50,FALSE))"
Range("D44").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-36]C4,Total_item_overview!R2C[-3]:R100000C[74],23,FALSE)),"""")"
Range("D45").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-37]C4,Total_item_overview!R2C[-3]:R100000C[74],24,FALSE)),"""")"
Range("D46").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-38]C4,Total_item_overview!R2C[-3]:R100000C[74],25,FALSE)),"""")"
Range("D47").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-39]C4,Total_item_overview!R2C[-3]:R100000C[74],33,FALSE)),"""")"
Range("D48").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-40]C4,Total_item_overview!R2C[-3]:R100000C[74],34,FALSE)),"""")"
Range("D49").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-41]C4,Total_item_overview!R2C[-3]:R100000C[74],35,FALSE)),"""")"
Range("D50").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-42]C4,Total_item_overview!R2C[-3]:R100000C[74],32,FALSE)),"""")"
Range("D51").Select
ActiveCell.FormulaR1C1 = _
"=IF(R43C4=""Yes"",(VLOOKUP(R[-43]C4,Total_item_overview!R2C[-3]:R100000C[74],31,FALSE)),"""")"
Range("L43").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",IFERROR(VLOOKUP(R8C4,Interspec!C[-11]:C[-1],6,0),""N.A.""))"
Range("L51").Select
ActiveCell.FormulaR1C1 = _
"=IF(R8C4="""","""",VLOOKUP(R[-43]C4,Total_item_overview!R2C[-11]:R100000C[66],61,FALSE))"
End With
Range("A6:N53").Select 'deze regels mogen weg, er zijn geen formules meer, dus moet er niet meer gekopieerd en geplakt worden.
Range("N53").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=-51
Range("A6").Select
Application.CutCopyMode = False
End Sub