VBA - Copy only visible rows

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,291
Office Version
  1. 365
Platform
  1. Windows
I have the following code to copy and paste some data
Code:
    Sheets("High Priority").Range("A4", Sheets("High Priority").Range("B56000").End(xlUp)).Copy Destination:=Sheets("to order").Range("B56000").End(xlUp).Offset(1)
    Sheets("High Priority").Range("K4", Sheets("High Priority").Range("K56000").End(xlUp)).Copy
    Sheets("to order").Range("D56000").End(xlUp).Offset(1).pastespecial xlValues

However it is copying all the data including the hidden rows.

how do I get around this?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try like this

Rich (BB code):
Sheets("High Priority").Range("A4", Sheets("High Priority").Range("B56000").End(xlUp)).SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("to order").Range("B56000").End(xlUp).Offset(1)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,710
Members
452,939
Latest member
WCrawford

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