View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Luke M Luke M is offline
external usenet poster
 
Posts: 2,722
Default Copying four filtered cells

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).C opy

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).C opy
'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
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"CousinExcel" wrote:

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




"Luke M" wrote:

Is it always the same 4 cells? How do you if it the filter will only give 4
results?
If what you are really wanting is to select all the results from the filter,
something like this:

Range("A2:A100").SpecialCells(xlCellTypeVisible).S elect
Selection.Copy

Where A2:A100 is the range you filtered, so that you won't get any extra
cells from the end of the workbook.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"CousinExcel" wrote: