Sub Weights()
ActiveWorkbook.Sheets("HazShipper").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim myLastRow As Long
Dim myWorksheet As Worksheet
Dim myLastRow2 As Long
Dim myWorksheet2 As Worksheet
Set myWorksheet = Worksheets("HazShipper")
Set myWorksheet2 = Worksheets("DGbyFLT")
myLastRow = myWorksheet.Cells(myWorksheet.Rows.Count, "A").End(xlUp).row
myLastRow2 = myWorksheet2.Cells(myWorksheet2.Rows.Count, "A").End(xlUp).row
Range("AJ2").Formula = "=P2"
Range("AK2").Formula = "=S2"
Range("AL2").Formula = "=IFERROR(VLOOKUP(U2,DGbyFLT!$A$2:$BA$" & myLastRow2 & ",53,0),""No Value"")"
Range("AM2").Formula = "=CLEAN(TRIM(AJ2))"
Range("AN2").Formula = "=CLEAN(TRIM(AK2))"
Range("AO2").Formula = "=CLEAN(TRIM(AM2))"
Range("AJ2:AO2").Select
Selection.AutoFill Destination:=Range("AJ2:AO" & myLastRow)
Columns("AM:AO").Select
Range("AO1").Activate
Selection.Copy
Range("AJ1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("AM:AO").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("AM2").Select
For i = 2 To myLastRow
Set mycell = myWorksheet.Range("AK" & i)
Set mycell2 = myWorksheet.Range("AD" & i)
If mycell.Value = "L" And mycell2.Value = "UN3363" Then
mycell.Offset(, 2).Formula = "=IFERROR(IF([B][COLOR=#ff0000]AL2=AJ2[/COLOR][/B],TRUE,FALSE),""ERROR"")"
Else
mycell.Offset(, 2).Formula = "=IF([B][COLOR=#ff0000]AL2=AJ2[/COLOR][/B],TRUE,FALSE)"
End If
Next
End Sub