Good afternoon all, Newbie here trying to make some code that I have copied work. Everything works apart from it doesn't delete the value from the cell of the last selection. It deletes all the previous ones. This is the code
Sub PrintCWO()
If Not ActiveSheet.Name Like "WK*" Then
MsgBox "Ensure correct worksheet selected"
Exit Sub
Application.ScreenUpdating = False
Else:
Count = 1
For i = 4 To 500
If LCase(Range("BB" & i).Value) = "y" Then
Area = Range("A" & i).Value
Zone = Range("B" & i).Value
Station = Range("C" & i).Value
Robot = Range("D" & i).Value
Desc = Range("E" & i).Value
Ref = Range("F" & i).Value
ReqDate = Range("G" & i).Value
Requestor = Range("H" & i).Value
Trades = Range("I" & i).Value
Gap = Range("J" & i).Value
Stoppage = Range("K" & i).Value
Priority = Range("L" & i).Value
Order = Range("N" & i).Value
Est = Range("T" & i).Value
Authorised = Range("BA" & i).Value
Sheets("CWO").Range("B1").Value = Area
Sheets("CWO").Range("C1").Value = Zone
Sheets("CWO").Range("D1").Value = Station
Sheets("CWO").Range("E1").Value = Robot
Sheets("CWO").Range("F1").Value = Desc
Sheets("CWO").Range("G1").Value = Ref
Sheets("CWO").Range("H1").Value = ReqDate
Sheets("CWO").Range("I1").Value = Requestor
Sheets("CWO").Range("J1").Value = Trades
Sheets("CWO").Range("K1").Value = Gap
Sheets("CWO").Range("L1").Value = Stoppage
Sheets("CWO").Range("M1").Value = Priority
Sheets("CWO").Range("O1").Value = Order
Sheets("CWO").Range("U1").Value = Est
Sheets("CWO").Range("V1").Value = Authorised
If Count = 1 Then
x = ActiveSheet.Name
Sheets("CWO").Activate
Application.Dialogs(xlDialogPrint).Show
Sheets(x).Activate
Else: Sheets("CWO").PrintOut
End If
Count = Count + 1
Range("BB" & i).Value = ""
End If
Next
End If
Application.ScreenUpdating = True
End Sub
Can anybody help please?
Thank you!
Sub PrintCWO()
If Not ActiveSheet.Name Like "WK*" Then
MsgBox "Ensure correct worksheet selected"
Exit Sub
Application.ScreenUpdating = False
Else:
Count = 1
For i = 4 To 500
If LCase(Range("BB" & i).Value) = "y" Then
Area = Range("A" & i).Value
Zone = Range("B" & i).Value
Station = Range("C" & i).Value
Robot = Range("D" & i).Value
Desc = Range("E" & i).Value
Ref = Range("F" & i).Value
ReqDate = Range("G" & i).Value
Requestor = Range("H" & i).Value
Trades = Range("I" & i).Value
Gap = Range("J" & i).Value
Stoppage = Range("K" & i).Value
Priority = Range("L" & i).Value
Order = Range("N" & i).Value
Est = Range("T" & i).Value
Authorised = Range("BA" & i).Value
Sheets("CWO").Range("B1").Value = Area
Sheets("CWO").Range("C1").Value = Zone
Sheets("CWO").Range("D1").Value = Station
Sheets("CWO").Range("E1").Value = Robot
Sheets("CWO").Range("F1").Value = Desc
Sheets("CWO").Range("G1").Value = Ref
Sheets("CWO").Range("H1").Value = ReqDate
Sheets("CWO").Range("I1").Value = Requestor
Sheets("CWO").Range("J1").Value = Trades
Sheets("CWO").Range("K1").Value = Gap
Sheets("CWO").Range("L1").Value = Stoppage
Sheets("CWO").Range("M1").Value = Priority
Sheets("CWO").Range("O1").Value = Order
Sheets("CWO").Range("U1").Value = Est
Sheets("CWO").Range("V1").Value = Authorised
If Count = 1 Then
x = ActiveSheet.Name
Sheets("CWO").Activate
Application.Dialogs(xlDialogPrint).Show
Sheets(x).Activate
Else: Sheets("CWO").PrintOut
End If
Count = Count + 1
Range("BB" & i).Value = ""
End If
Next
End If
Application.ScreenUpdating = True
End Sub
Can anybody help please?
Thank you!