Copy & Paste Visible cells only top 10 filtered range

harinsh

Active Member
Joined
Feb 7, 2012
Messages
273
Hi Team,

Can anyone please help me out how to select top 10 visible range of cells those were filtered and copy paste the same data into different sheet. I need to update this code to updated in vba macro code. Please provide an resolution in order to fix this.

NOte: Data is dynamic and it will change every time which update.

Thanks in advance.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hello Harinsh,

There is not much information, but here is a very simple peace of code which uses top10 filtering and copies the data to sheet2.

You need to modify it a little.

Code:
Sub Test()
Dim X As Range
Dim Y As Range
Set X = Columns("A:IV")
Set Y = Range("1:11")
Sheets("Sheet1").Activate
X.Select
Selection.AutoFilter Field:=3 'Not needed, just resets the filter if the macro is used several times in a row
Selection.AutoFilter Field:=3, Criteria1:="10", Operator:=xlTop10Items 'Insert the correct filter info
Cells.Copy
Sheets("Sheet2").Activate
ActiveSheet.Paste
End Sub

-Grazier
 
Upvote 0
Hi Grazier,

I'm really sorry, not able to fulfill my requirement with given code. Let me explain in details with an example.

I have data with lots of columns assume A to F. I would like to sort with total (Decending order) and if 'Zero' comes in any top 10 cells and then that row should not reflect for calculation (can filter it in macro). Later on I need to copy top 10 (after excluding 'Zero' contain rows) and paste it into different sheet.

It should get copy & paste only visible cells. Please provide your suggestion how better way to do it this and also help with codes.

Thanks,

Month
JanFebMarAprTotal
AAAAA5134345235131983
BBBBB4627132014621838
CCCCC5772235495771926
DDDDD62003750995
EEEEEE6932332926931911
FFFFFF2783380278894
GGGGG4813433334811638
HHHHH41604004161232
IIIIIIIIII3691454423691325
JJJJJJJJ3903362193901335

<colgroup><col><col span="5"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,639
Members
449,325
Latest member
Hardey6ix

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