PC Review


Reply
Thread Tools Rate Thread

Copy autofilter row by row

 
 
=?Utf-8?B?U2hsb21pdA==?=
Guest
Posts: n/a
 
      12th Nov 2006
Hi,
I made autofilter on range in sheet1 and I need to copy it (only the rows
after the filter) for another range in sheet2 but I need to do it row by row
because for each row in column 3 i need the value from col 5.

For example:
Sheet1:
1,5,aa,33,bbb
2,6,bb,45,ccc

Sheet2: (after the copy)
1,5,bbb,33,bbb
2,6,ccc,45,ccc

How can I do it?

thanks,
Shlomit
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      12th Nov 2006
It looks like you could copy|Paste the visible cells in the autofilter range,
then come back to copy|paste the 5th column over the 3rd column.

If that's something you want to try:

Option Explicit
Sub testme()

Dim myRng As Range
Dim DestCell As Range

With Worksheets("sheet2")
'next open cell in column A???
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

With Worksheets("sheet1")
With .AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible) _
.Cells.Count = 1 Then
MsgBox "nothing visible in the filter!"
Exit Sub
End If
Set myRng = .Resize(.Rows.Count - 1, .Columns.Count) _
.Offset(1, 0).Cells.SpecialCells(xlCellTypeVisible)
myRng.Copy _
Destination:=DestCell

myRng.Columns(5).Copy _
Destination:=DestCell.Offset(0, 2)
End With
End With

End Sub

I didn't know where to paste, so I just used the next available cell in column
A.

Shlomit wrote:
>
> Hi,
> I made autofilter on range in sheet1 and I need to copy it (only the rows
> after the filter) for another range in sheet2 but I need to do it row by row
> because for each row in column 3 i need the value from col 5.
>
> For example:
> Sheet1:
> 1,5,aa,33,bbb
> 2,6,bb,45,ccc
>
> Sheet2: (after the copy)
> 1,5,bbb,33,bbb
> 2,6,ccc,45,ccc
>
> How can I do it?
>
> thanks,
> Shlomit


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I copy an autofilter using a macro? =?Utf-8?B?QXN0b25naXptbw==?= Microsoft Excel Programming 12 23rd Nov 2006 09:56 PM
Autofilter copy Mike Fogleman Microsoft Excel Programming 3 5th Dec 2005 08:23 PM
Autofilter and Copy and Paste =?Utf-8?B?U2hhd24=?= Microsoft Excel Programming 1 4th Mar 2005 05:43 PM
AutoFilter and copy Rich Microsoft Excel Programming 2 27th Sep 2004 09:48 PM
AUTOFILTER copy and paste RJ Kelly Microsoft Excel Programming 1 8th Jun 2004 11:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 AM.