Simplify Copy and Paste between sheets

Lloydlobo

New Member
Joined
May 19, 2014
Messages
34
Trying to simplify the following code as there are a number if times it copies and pastes from the "Cust OrderInv" sheet to the "Details" sheet.

Many thanks

Sheets("Cust OrderInv").Select
ActiveSheet.Unprotect
ActiveSheet.Range("$A$95:$B$229").AutoFilter Field:=2, Criteria1:="<>"
Range("F98:F152").Select
Selection.Copy
Sheets("Details").Select
Range("A5000").Select
Selection.End(xlUp).Select
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
How about
VBA Code:
   With Sheets("Cust OrderInv")
      .Unprotect
      .Range("$A$95:$B$229").AutoFilter Field:=2, Criteria1:="<>"
      .AutoFilter.Range.Offset(1).Columns("F").Copy
      Sheets("Details").Range("A" & Rows.Count).End(xlUp).Offset(, 3).PasteSpecial xlPasteValues, , , True
   End With
 
Upvote 0
VBA Code:
Code:
   With Sheets("Cust OrderInv")
      .Unprotect
      .Range("$A$95:$B$229").AutoFilter Field:=2, Criteria1:="<>"
      .AutoFilter.Range.Offset(1).Columns("F").Copy
      Sheets("Details").Range("A" & Rows.Count).End(xlUp).Offset(, 3).PasteSpecial xlPasteValues, , , True
   End With
Thanks. Will try it out.
 
Upvote 0

Forum statistics

Threads
1,212,927
Messages
6,110,730
Members
448,294
Latest member
jmjmjmjmjmjm

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