Hello
After a prompt from MARK858 I have been re-writing my existing code without using select and code that doesn't need to be there. The code below is what I have come up with. It works as it is supposed to. My question is:
Is there anything I could do to clean this code up more, or do things better?
Interstingly, this code runs in about the 0.50-0.60 sec range. The code it replaced runs in around 0.90 sec.
After a prompt from MARK858 I have been re-writing my existing code without using select and code that doesn't need to be there. The code below is what I have come up with. It works as it is supposed to. My question is:
Is there anything I could do to clean this code up more, or do things better?
Interstingly, this code runs in about the 0.50-0.60 sec range. The code it replaced runs in around 0.90 sec.
Code:
Sub f2()
Application.ScreenUpdating = False
Dim ws As Worksheet
Set ws = Sheet1
Dim aRng As Range
Dim bRng As Range
Set aRng = ws.Range("A1").End(xlDown)
With Range(aRng, aRng.Offset(0, 13))
.Copy aRng.Offset(1, 0)
.Value = .Value
Set bRng = ws.Range("a1").End(xlDown).Offset(-1, 21)
With Range(bRng, bRng.Offset(, 8))
.Copy bRng.Offset(1, 0)
.Value = .Value
Application.ActivePrinter = "Brother QL-700 on Ne05:"
With Sheet3
.Visible = True
.PrintOut Copies:=1
.Visible = False
Application.ActivePrinter = "FX DocuPrint P205 b on Ne03:"
Dim ws2 As Worksheet
Set ws2 = Sheet4
Dim cRng As Range
Dim dRng As Range
Set cRng = ws2.Range("a60")
Set dRng = ws2.Range("a58")
With cRng
.Cut Destination:=dRng
With ws2
.PrintOut Copies:=1
Set cRng = ws2.Range("a60")
Set dRng = ws2.Range("a58")
With dRng
.Cut Destination:=cRng
Set cRng = ws2.Range("d60")
Set dRng = ws2.Range("d58")
With cRng
.Cut Destination:=dRng
With ws
.PrintOut Copies:=1
Set cRng = ws2.Range("d60")
Set dRng = ws2.Range("d58")
With dRng
.Cut Destination:=cRng
Set cRng = ws2.Range("h60")
Set dRng = ws2.Range("h58")
With cRng
.Cut Destination:=dRng
With ws
.PrintOut Copies:=1
Set cRng = ws2.Range("h60")
Set dRng = ws2.Range("h58")
With dRng
.Cut Destination:=cRng
Dim ws3 As Worksheet
Set ws3 = Sheet5
Dim eRng As Range
Dim fRng As Range
Dim gRng As Range
Dim hRng As Range
Dim iRng As Range
Set eRng = ws3.Range("b55")
Set fRng = ws3.Range("b56")
Set gRng = ws3.Range("b57")
Set hRng = ws3.Range("b58")
Set iRng = ws3.Range("b43")
Set jRng = ws3.Range("B40:B42,B44:B45,B50:B54,B59:B61")
With eRng
.Value = Sheet6.Range("o2")
With fRng
.Value = Sheet6.Range("p2")
With gRng
.Value = Sheet6.Range("q2")
With hRng
.Value = Sheet6.Range("r2")
With iRng
.Formula = "=TODAY()"
With jRng
.ClearContents
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
End With
'End With
Application.ScreenUpdating = True
End Sub