mariusnielsen
New Member
- Joined
- Mar 12, 2011
- Messages
- 4
I have a piece of code that I need to exit sub if criteria is not met. Not sure how to solve this with exit or end sub...Tried with else function but cannot get it to work.
Sub COPY_PARCEL_HEADER_2()
LR = Sheets("SAP MMT").Cells(Rows.Count, "C").End(xlUp).Row
myCopyRow = LR + 1
lastrow = Sheets("PARCELS").Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
Sheets("SAP MMT").Cells(myCopyRow, "B") = "Parcel id:"
Sheets("SAP MMT").Cells(myCopyRow, "E") = "Gross"
Sheets("SAP MMT").Cells(myCopyRow, "G") = "Kgs"
Sheets("SAP MMT").Cells(myCopyRow, "H") = "Net"
Sheets("SAP MMT").Cells(myCopyRow, "J") = "Kgs"
Sheets("SAP MMT").Cells(myCopyRow, "K") = "Lenght "
Sheets("SAP MMT").Cells(myCopyRow, "M") = "Width "
Sheets("SAP MMT").Cells(myCopyRow, "O") = "Height "
Sheets("SAP MMT").Range("A" & myCopyRow, "P" & myCopyRow).Font.FontStyle = "Bold"
For myRow = 4 To lastrow
If Sheets("Parcels").Cells(myRow, "A") = 2 And Sheets("Parcels").Cells(myRow, "T") <> "" Then
Sheets("SAP MMT").Cells(myCopyRow, "C") = Sheets("PARCELS").Cells(myRow, "T")
Sheets("SAP MMT").Cells(myCopyRow, "F") = Sheets("PARCELS").Cells(myRow, "N")
Sheets("SAP MMT").Cells(myCopyRow, "I") = Sheets("PARCELS").Cells(myRow, "O")
Sheets("SAP MMT").Cells(myCopyRow, "L") = Sheets("PARCELS").Cells(myRow, "P")
Sheets("SAP MMT").Cells(myCopyRow, "N") = Sheets("PARCELS").Cells(myRow, "Q")
Sheets("SAP MMT").Cells(myCopyRow, "P") = Sheets("PARCELS").Cells(myRow, "R")
myCopyRow = myCopyRow + 1
End If
Next myRow
Application.ScreenUpdating = True
End Sub
Sub COPY_PARCEL_HEADER_2()
LR = Sheets("SAP MMT").Cells(Rows.Count, "C").End(xlUp).Row
myCopyRow = LR + 1
lastrow = Sheets("PARCELS").Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
Sheets("SAP MMT").Cells(myCopyRow, "B") = "Parcel id:"
Sheets("SAP MMT").Cells(myCopyRow, "E") = "Gross"
Sheets("SAP MMT").Cells(myCopyRow, "G") = "Kgs"
Sheets("SAP MMT").Cells(myCopyRow, "H") = "Net"
Sheets("SAP MMT").Cells(myCopyRow, "J") = "Kgs"
Sheets("SAP MMT").Cells(myCopyRow, "K") = "Lenght "
Sheets("SAP MMT").Cells(myCopyRow, "M") = "Width "
Sheets("SAP MMT").Cells(myCopyRow, "O") = "Height "
Sheets("SAP MMT").Range("A" & myCopyRow, "P" & myCopyRow).Font.FontStyle = "Bold"
For myRow = 4 To lastrow
If Sheets("Parcels").Cells(myRow, "A") = 2 And Sheets("Parcels").Cells(myRow, "T") <> "" Then
Sheets("SAP MMT").Cells(myCopyRow, "C") = Sheets("PARCELS").Cells(myRow, "T")
Sheets("SAP MMT").Cells(myCopyRow, "F") = Sheets("PARCELS").Cells(myRow, "N")
Sheets("SAP MMT").Cells(myCopyRow, "I") = Sheets("PARCELS").Cells(myRow, "O")
Sheets("SAP MMT").Cells(myCopyRow, "L") = Sheets("PARCELS").Cells(myRow, "P")
Sheets("SAP MMT").Cells(myCopyRow, "N") = Sheets("PARCELS").Cells(myRow, "Q")
Sheets("SAP MMT").Cells(myCopyRow, "P") = Sheets("PARCELS").Cells(myRow, "R")
myCopyRow = myCopyRow + 1
End If
Next myRow
Application.ScreenUpdating = True
End Sub