Copy And Paste Depening On Criteria

blood_Milk_sky

New Member
Joined
Nov 16, 2016
Messages
10
Hey,

I was just wondering if anyone could help me with the below. I am trying to only Copy and Paste the rows that exceed "0", I have tried running this code but every time I do I get a run time error. could anyone help me please? an any improvements or suggestions would be greatly appreciated

many thanks

BMS

Code:
Sub ADDTOORDER()

    Sheets("Menu").Select
    Range("B7:D68").AutoFilter Field:=3, Criteria1:=">0", Operator:=xlAnd
    Range("B7:D68").Copy
    Sheets("LensOrder").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
    Sheets("Menu").Range("C3").Select
    Selection.ClearContents
    Range("QTYS").Select
    Selection.ClearContents
    Range("C3").Select
    
End Sub
 
Try this



Code:
Sub ADDTOORDER()
Dim Sh As Worksheet, C As Worksheet, Last As Long
Set Sh = Sheets("Menu")
Set C = Sheets("LensOrder")
With Sh
Last = .Cells(Rows.Count, 2).End(xlUp).Row
    .Range("B7:D" & Last).AutoFilter Field:=2, Criteria1:=">0", Operator:=xlAnd
    .Range("B7:D" & Last).SpecialCells(xlCellTypeVisible).Copy
    C.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
    Sheets("Menu").Range("C3").Select
   .Range("B7:D" & Last).AutoFilter
End With
End Sub
 
Upvote 0
Thank you for your response. I have tried the Code and it only Copys an paste the first row of the range B7:d68 to the sheet "LensOrder"
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top