Copying four filtered cells

C

CousinExcel

Thanks to Luke, Edhardo, Jacob Scaria.
But my problem is going on.

Copying four filtered cells by means of macro ?

we know that there will be maximum 4 cells as result of filtering (or
we can also assume that we will copy only first four cells (grades))

In Luke' s I have this problem:
For example I will copy to A2 from the filtered place.
In A6, A7.... THERE ARE DATA.
If I make 100 as Luke' s suggestion these A6, A7... are overwritten
 
L

Luke M

Please stop recreating threads. It's easier for us to see what's already been
suggested if it's all in one thread.

For the coding I gave, the A2:A100 is the range you are "filtering" not your
destination. Let's say you filter A2:A100 and it displays cells A3, A10, A12,
and A16. The code:
Range("A2:A100").SpecialCells(xlCellTypeVisible).Copy

Will only copy those four cells. You could then pick your destination cell
and paste, as in:
Range("Z1").select
Activesheet.paste

Of, perhaps we could do an intermediate step to make sure no extra data is
copied over. Using column AA as an intermediate step, and Z1 as the final
destination:

Range("A2:A100").SpecialCells(xlCellTypeVisible).Copy
'Paste into helper column
Range("AA1").select
ActiveSheet.Paste
'Remove unwanted data
Range("AA5:AA65000").ClearContents
Range("AA1:AA4").copy
'Send to desired destination
Range("Z1").select
ActiveSheet.Paste
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top