Sub CopyColumns()
'workbook and sheet declarations
Dim tWB As Workbook: Set tWB = ThisWorkbook
Dim tWS As Worksheet: Set tWS = tWB.Sheets("raw materials")
Dim xWB As Workbook: Set xWB = Workbooks("order book macro.xlsm")
Dim xWS As Worksheet: Set xWS = xWB.Sheets("order book")
'last row declarations
Dim tLRow As Long: tLRow = tWS.Cells(tWS.Cells.Rows.Count, 1).End(xlUp).Row
Dim xLRow As Long: xLRow = xWS.Cells(xWS.Cells.Rows.Count, 1).End(xlUp).Row
'copy columns
With tWS
.Range("C2:C" & tLRow).Copy xWS.Cells(xLRow + 1, 1)
.Range("H2:H" & tLRow).Copy xWS.Cells(xLRow + 1, 2)
.Range("D2:E" & tLRow).Copy xWS.Cells(xLRow + 1, 3)
' .Range("D2:D" & tLRow).Copy xWS.Cells(xLRow + 1, 3)
' .Range("E2:E" & tLRow).Copy xWS.Cells(xLRow + 1, 4)
.Range("J2:J" & tLRow).Copy xWS.Cells(xLRow + 1, 5)
.Range("L2:N" & tLRow).Copy xWS.Cells(xLRow + 1, 6)
' .Range("L2:L" & tLRow).Copy xWS.Cells(xLRow + 1, 6)
' .Range("M2:M" & tLRow).Copy xWS.Cells(xLRow + 1, 7)
' .Range("N2:N" & tLRow).Copy xWS.Cells(xLRow + 1, 8)
.Range("W2:W" & tLRow).Copy xWS.Cells(xLRow + 1, 9)
.Range("W2:W" & tLRow).Copy xWS.Cells(xLRow + 1, 10) 'same conten to 2 different columns?
.Range("P2:P" & tLRow).Copy xWS.Cells(xLRow + 1, 11)
.Range("X2:Y" & tLRow).Copy xWS.Cells(xLRow + 1, 12)
' .Range("X2:X" & tLRow).Copy xWS.Cells(xLRow + 1, 12)
' .Range("y2:y" & tLRow).Copy xWS.Cells(xLRow + 1, 13)
End With
'change worksheet to suit
With xWS
With .Range("X2:X" & xLRow)
.Value = Evaluate("=IF(" & .Address & "="""", ""still on track"" ," & .Address & ")")
End With
With .Range("Y2:Y" & xLRow)
.Value = Evaluate("=IF(" & .Address & "=""""" & "," & .Offset(0, -11).Address & "," & .Address & ")")
End With
End With
End Sub