How to copy only visible cells in Excel using VBA

Consider an Excel sheet which has list of customers from two different regions, say A and B. If we have to copy only the customers from region A into sheet 2, Apply filter to region column for criteria A, select the visible data and use the below code to copy only the visible cells:

Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Sheet2").select
ActiveSheet.Paste

This will copy only the visible cells into Sheet 2.
 
Share:

0 comments:

Post a Comment